[FFmpeg-devel] Copy user data in H264 for captions

Michael Niedermayer michaelni at gmx.at
Wed Oct 30 21:43:57 CET 2013


On Wed, Oct 30, 2013 at 06:20:14PM +0530, Radha Krishna Ramachandruni wrote:
> Patch for copying ITU_T registered user data to AVFrame for extracting
> closed captions.
> 
> 
> rkrishna

>  libavcodec/h264.c     |   17 ++-
>  libavcodec/h264.h     |    9 +
>  libavcodec/h264_sei.c |  228 ++++++++++++++++++++++++++++++++++++++++++++------
>  libavutil/common.h    |    5 +
>  4 files changed, 228 insertions(+), 31 deletions(-)
> 6669e36e8a72f265bc701f5263151652aa42c22f  ffmpeg-h264cc.patch
> diff --git a/mythtv/external/FFmpeg/libavcodec/h264.c b/mythtv/external/FFmpeg/libavcodec/h264.c
> index 3a83b4b..e8c0735 100644
> --- a/mythtv/external/FFmpeg/libavcodec/h264.c
> +++ b/mythtv/external/FFmpeg/libavcodec/h264.c
> @@ -1742,10 +1742,19 @@
>  
>      pic->f.reference            = h->droppable ? 0 : h->picture_structure;
>      pic->f.coded_picture_number = h->coded_picture_number++;
>      pic->field_picture          = h->picture_structure != PICT_FRAME;
>  
> +
> +    /* Put ATSC captions cached from parse_user_data into the correct frame */
> +    memcpy(pic->f.atsc_cc_buf, h->tmp_atsc_cc_buf, h->tmp_atsc_cc_len);
> +    pic->f.atsc_cc_len = h->tmp_atsc_cc_len;
> +    h->tmp_atsc_cc_len = 0;
> +    memcpy(pic->f.scte_cc_buf, h->tmp_scte_cc_buf, h->tmp_scte_cc_len);
> +    pic->f.scte_cc_len = h->tmp_scte_cc_len;
> +    h->tmp_scte_cc_len = 0;

there are no such fields on AVFrame


> +
>      /*
>       * Zero key_frame here; IDR markings per slice in frame or fields are ORed
>       * in later.
>       * See decode_nal_units().
>       */

> @@ -2775,12 +2784,11 @@
>       * and a bad error table. Further, the error count goes to
>       * INT_MAX when called for bottom field, because mb_y is
>       * past end by one (callers fault) and resync_mb_y != 0
>       * causes problems for the first MB line, too.
>       */
> -    if (CONFIG_ERROR_RESILIENCE &&
> -        !FIELD_PICTURE && h->current_slice && !h->sps.new) {
> +    if (CONFIG_ERROR_RESILIENCE && !FIELD_PICTURE && h->current_slice && !h->sps.new && h->avctx->skip_frame < AVDISCARD_ALL) {
>          h->er.cur_pic  = h->cur_pic_ptr;
>          ff_er_frame_end(&h->er);
>      }
>      emms_c();
>  

looks unrelated


> @@ -4519,12 +4527,13 @@
>                  case NAL_SLICE:
>                      first_slice = hx->nal_unit_type;
>                  }
>  
>              // FIXME do not discard SEI id
> -            if (avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0)
> -                continue;
> +            if (avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0
> +            		&& hx->nal_unit_type != NAL_SLICE && hx->nal_unit_type != NAL_SEI)
> +            	continue;
>  

looks unrelated
also contains tabs, which arent allowed in c files in ffmpeg git

also the patch doesnt apply

patching file libavcodec/h264.c
Hunk #1 succeeded at 1951 with fuzz 2 (offset 209 lines).
Hunk #2 FAILED at 2784.
Hunk #3 FAILED at 4528.
2 out of 3 hunks FAILED -- saving rejects to file libavcodec/h264.c.rej
patching file libavcodec/h264.h
Hunk #1 succeeded at 668 (offset 30 lines).
patching file libavcodec/h264_sei.c
Hunk #1 FAILED at 92.
Hunk #2 FAILED at 221.
2 out of 2 hunks FAILED -- saving rejects to file libavcodec/h264_sei.c.rej
patching file libavutil/common.h


[...]
> @@ -221,10 +394,11 @@
>                  return -1;
>              break;
>          case SEI_TYPE_USER_DATA_ITU_T_T35:
>              if(decode_user_data_itu_t_t35(h, size) < 0)
>                  return -1;
> +            skip_bits(&h->gb, 8*size);

this looks wrong

>              break;
>          case SEI_TYPE_USER_DATA_UNREGISTERED:
>              if(decode_unregistered_user_data(h, size) < 0)
>                  return -1;
>              break;
> diff --git a/mythtv/external/FFmpeg/libavutil/common.h b/mythtv/external/FFmpeg/libavutil/common.h
> index beaf9f7..0427466 100644
> --- a/mythtv/external/FFmpeg/libavutil/common.h
> +++ b/mythtv/external/FFmpeg/libavutil/common.h
> @@ -32,10 +32,15 @@
>  #include <math.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
>  
> +#ifndef UINT64_C
> +#define UINT64_C(c) (c ## ULL)
> +#endif
> +

unrelated


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131030/3e36e597/attachment.asc>


More information about the ffmpeg-devel mailing list