diff options
author | Marton Balint <cus@passwd.hu> | 2012-10-14 19:17:22 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-21 18:22:50 +0200 |
commit | d6e95669496a89d186f923c34bcaf7d86b7cd59c (patch) | |
tree | 534e0341bce3186476a3d9985e7fb42fcbd608b1 /libavcodec | |
parent | 40ceb6d49f19a8c1795b3f453cd7c0b7e540dd81 (diff) | |
download | ffmpeg-d6e95669496a89d186f923c34bcaf7d86b7cd59c.tar.gz |
h264: add support for AFD detection
Signed-off-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Kieran Kunhya <kierank@ob-encoder.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h264.h | 1 | ||||
-rw-r--r-- | libavcodec/h264_sei.c | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 4d07a8ac4d..298f983d3b 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -130,6 +130,7 @@ enum { typedef enum { SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) SEI_TYPE_PIC_TIMING = 1, ///< picture timing + SEI_TYPE_USER_DATA_ITU_T_T35 = 4, ///< user data registered by ITU-T Recommendation T.35 SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync) } SEI_Type; diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 81edeb27c6..62320e2d6a 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -95,6 +95,43 @@ static int decode_picture_timing(H264Context *h){ return 0; } +static int decode_user_data_itu_t_t35(H264Context *h, int size) { + MpegEncContext * const s = &h->s; + uint32_t user_identifier; + int dtg_active_format; + + if (size < 7) + return -1; + size -= 7; + + skip_bits(&s->gb, 8); // country_code + skip_bits(&s->gb, 16); // provider_code + user_identifier = get_bits_long(&s->gb, 32); + + switch (user_identifier) { + case 0x44544731: // "DTG1" - AFD_data + if (size < 1) + return -1; + skip_bits(&s->gb, 1); + if (get_bits(&s->gb, 1)) { + skip_bits(&s->gb, 6); + if (size < 2) + return -1; + skip_bits(&s->gb, 4); + dtg_active_format = get_bits(&s->gb, 4); + s->avctx->dtg_active_format = dtg_active_format; + } else { + skip_bits(&s->gb, 6); + } + break; + default: + skip_bits(&s->gb, size * 8); + break; + } + + return 0; +} + static int decode_unregistered_user_data(H264Context *h, int size){ MpegEncContext * const s = &h->s; uint8_t user_data[16+256]; @@ -191,6 +228,10 @@ int ff_h264_decode_sei(H264Context *h){ if(decode_picture_timing(h) < 0) return -1; break; + case SEI_TYPE_USER_DATA_ITU_T_T35: + if(decode_user_data_itu_t_t35(h, size) < 0) + return -1; + break; case SEI_TYPE_USER_DATA_UNREGISTERED: if(decode_unregistered_user_data(h, size) < 0) return -1; |