[FFmpeg-devel] [VA decode] [PATCH] calculation of next marker for MPEG-4 streams

Michael Niedermayer michaelni at gmx.at
Mon Oct 8 23:49:04 CEST 2012


On Mon, Oct 08, 2012 at 07:59:04PM +0530, anuj mittal wrote:
> On Mon, Oct 8, 2012 at 5:17 PM, anuj mittal <am.devel at gmail.com> wrote:
> > On Mon, Oct 8, 2012 at 4:44 PM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> >> anuj mittal <am.devel <at> gmail.com> writes:
> >>
> >>> Attached is a patch that implements this. Please comment.
> >>
> >>> +    if (s->resync_marker)
> >>> +    {
> >>> +        if (s->pict_type == FF_I_TYPE)
> >>> +        {
> >>
> >> ...
> >>
> >>> +        }
> >>> +        else /* P, B or S type */
> >>> +        {
> >>
> >> Please adhere to the coding style of the file / FFmpeg:
> >>
> >> if (s->resync_marker) {
> >>     if (s->pict_type == FF_I_TYPE) {
> >> ...
> >>     } else { /* P, B or S type */
> >>
> >> Thank you, Carl Eugen
> >
> > Thank you. Attached is the patch with the changes.
> >
> 
> Take 3: Corrected - had overlooked the I type. Attached is the
> corrected patch. Please comment.
> 
> Thank you.
> 
> Anuj

>  h263.h       |    2 +-
>  h263dec.c    |    2 +-
>  ituh263dec.c |   29 ++++++++++++++++++++++++-----
>  3 files changed, 26 insertions(+), 7 deletions(-)
> 55234a86a63c456eb9fe4657e9cf8ec49dd9782b  0001-Check-resync-marker-only-when-enabled.-Also-check-fo.patch
> From a02de1c918968669969612022a3debbc50a97058 Mon Sep 17 00:00:00 2001
> From: Anuj Mittal <am.devel at gmail.com>
> Date: Mon, 8 Oct 2012 15:04:47 +0530
> Subject: [PATCH] Check resync marker only when enabled. Also check for the
>  resync_marker based on vop coding type and
>  vop_fcode_forward and vop_fcode_backward.
> 
> ---
>  lib/ffmpeg/libavcodec/h263.h       |    2 +-
>  lib/ffmpeg/libavcodec/h263dec.c    |    2 +-
>  lib/ffmpeg/libavcodec/ituh263dec.c |   29 ++++++++++++++++++++++++-----
>  3 files changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/ffmpeg/libavcodec/h263.h b/lib/ffmpeg/libavcodec/h263.h
> index 0c11514..9377bce 100644
> --- a/lib/ffmpeg/libavcodec/h263.h
> +++ b/lib/ffmpeg/libavcodec/h263.h
> @@ -110,7 +110,7 @@ int av_const h263_get_picture_format(int width, int height);
>  
>  void ff_clean_h263_qscales(MpegEncContext *s);
>  int ff_h263_resync(MpegEncContext *s);
> -const uint8_t *ff_h263_find_resync_marker(const uint8_t *p, const uint8_t *end);
> +const uint8_t *ff_h263_find_resync_marker(MpegEncContext *s, const uint8_t *p, const uint8_t *end);
>  int ff_h263_get_gob_height(MpegEncContext *s);
>  void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code);
>  
> diff --git a/lib/ffmpeg/libavcodec/h263dec.c b/lib/ffmpeg/libavcodec/h263dec.c
> index fa476d9..55a050b 100644
> --- a/lib/ffmpeg/libavcodec/h263dec.c
> +++ b/lib/ffmpeg/libavcodec/h263dec.c
> @@ -162,7 +162,7 @@ static int decode_slice(MpegEncContext *s){
>  
>      if (s->avctx->hwaccel) {
>          const uint8_t *start= s->gb.buffer + get_bits_count(&s->gb)/8;
> -        const uint8_t *end  = ff_h263_find_resync_marker(start + 1, s->gb.buffer_end);
> +        const uint8_t *end  = ff_h263_find_resync_marker(s, start + 1, s->gb.buffer_end);
>          skip_bits_long(&s->gb, 8*(end - start));
>          return s->avctx->hwaccel->decode_slice(s->avctx, start, end - start);
>      }
> diff --git a/lib/ffmpeg/libavcodec/ituh263dec.c b/lib/ffmpeg/libavcodec/ituh263dec.c
> index 9c81bcb..ca4e0f2 100644
> --- a/lib/ffmpeg/libavcodec/ituh263dec.c
> +++ b/lib/ffmpeg/libavcodec/ituh263dec.c
> @@ -210,16 +210,35 @@ static int h263_decode_gob_header(MpegEncContext *s)
>   * @param end pointer to the end of the buffer
>   * @return pointer to the next resync_marker, or end if none was found
>   */
> -const uint8_t *ff_h263_find_resync_marker(const uint8_t *restrict p, const uint8_t * restrict end)
> +const uint8_t *ff_h263_find_resync_marker(MpegEncContext *s, const uint8_t *restrict p, const uint8_t * restrict end)
>  {
>      assert(p < end);
>  
>      end-=2;
>      p++;
> -    for(;p<end; p+=2){
> -        if(!*p){
> -            if     (!p[-1] && p[1]) return p - 1;
> -            else if(!p[ 1] && p[2]) return p;

> +    if(s->resync_marker){

this should be in a separet patch


    
    
> +        if(s->pict_type == FF_I_TYPE){
> +            for(;p<end; p+=2){
> +                if(!*p){
> +                    if     (!p[-1] && ((p[1] >> 7) == 1)) return p - 1;
> +                    else if(!p[ 1] && ((p[2] >> 7) == 1)) return p;
> +                }
> +            }
> +        }
> +        else{ /* P, B or S type */
> +            unsigned int f_code = s->f_code;
> +
> +            if(s->pict_type == FF_B_TYPE){
> +                if(f_code < s->b_code)
> +                    f_code = s->b_code;
> +            }
> +
> +            for(;p<end; p+=2){
> +                if(!*p){
> +                    if      (!p[-1] && ((p[1] >> (8 - f_code)) == 1)) return p - 1;
> +                    else if (!p[ 1] && ((p[2] >> (8 - f_code)) == 1)) return p;
> +                }
> +            }

using ff_mpeg4_get_video_packet_prefix_length() should allow this to
be simplified

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- 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/20121008/a052698c/attachment.asc>


More information about the ffmpeg-devel mailing list