summaryrefslogtreecommitdiff
path: root/libavcodec/h264_sei.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-06-28 12:13:05 +0200
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-06-30 15:34:38 +0200
commit271ce76d317c5432e151216cf23f12b77ed6cb7e (patch)
tree6ab18a33d1ac6d090aa187c942e26834491aff95 /libavcodec/h264_sei.c
parent0bfab80a0d9fce0180e8aa2a947267f89b725091 (diff)
h264: Parse registered data SEI message and AFD value
Partially based on code by Marton Balint and Kieran Kunhya. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/h264_sei.c')
-rw-r--r--libavcodec/h264_sei.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 0e99f05cc2..fe85ef1aff 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -42,6 +42,7 @@ void ff_h264_reset_sei(H264Context *h)
h->sei_buffering_period_present = 0;
h->sei_frame_packing_present = 0;
h->sei_display_orientation_present = 0;
+ h->sei_reguserdata_afd_present = 0;
}
static int decode_picture_timing(H264Context *h)
@@ -102,6 +103,51 @@ static int decode_picture_timing(H264Context *h)
return 0;
}
+static int decode_registered_user_data(H264Context *h, int size)
+{
+ uint32_t country_code;
+ uint32_t user_identifier;
+ int flag;
+
+ if (size < 7)
+ return AVERROR_INVALIDDATA;
+ size -= 7;
+
+ country_code = get_bits(&h->gb, 8); // itu_t_t35_country_code
+ if (country_code == 0xFF) {
+ skip_bits(&h->gb, 8); // itu_t_t35_country_code_extension_byte
+ size--;
+ }
+
+ /* itu_t_t35_payload_byte follows */
+ skip_bits(&h->gb, 8); // terminal provider code
+ skip_bits(&h->gb, 8); // terminal provider oriented code
+ user_identifier = get_bits_long(&h->gb, 32);
+
+ switch (user_identifier) {
+ case MKBETAG('D', 'T', 'G', '1'): // afd_data
+ if (size-- < 1)
+ return AVERROR_INVALIDDATA;
+ skip_bits(&h->gb, 1); // 0
+ flag = get_bits(&h->gb, 1); // active_format_flag
+ skip_bits(&h->gb, 6); // reserved
+
+ if (flag) {
+ if (size-- < 1)
+ return AVERROR_INVALIDDATA;
+ skip_bits(&h->gb, 4); // reserved
+ h->active_format_description = get_bits(&h->gb, 4);
+ h->sei_reguserdata_afd_present = 1;
+ }
+ break;
+ default:
+ skip_bits(&h->gb, size * 8);
+ break;
+ }
+
+ return 0;
+}
+
static int decode_unregistered_user_data(H264Context *h, int size)
{
uint8_t user_data[16 + 256];
@@ -247,6 +293,9 @@ int ff_h264_decode_sei(H264Context *h)
case SEI_TYPE_PIC_TIMING: // Picture timing SEI
ret = decode_picture_timing(h);
break;
+ case SEI_TYPE_USER_DATA_REGISTERED:
+ ret = decode_registered_user_data(h, size);
+ break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
ret = decode_unregistered_user_data(h, size);
break;