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

Michael Niedermayer michaelni at gmx.at
Tue Oct 9 13:51:04 CEST 2012


On Tue, Oct 09, 2012 at 12:23:19PM +0530, anuj mittal wrote:
> On Tue, Oct 9, 2012 at 3:19 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Mon, Oct 08, 2012 at 07:59:04PM +0530, anuj mittal wrote:
> 
> >>
> >>
> >>      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
> 
> Thanks. Attached is the 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
> >
> 
> Yes, thank you for pointing me to it. Attached is the patch. Please comment.
> 
> Thank you.
> 
> Anuj

>  ituh263dec.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 711188ccd52e64fde501c5aafb2ba6387385b368  0002-Check-for-the-resync_marker-based-on-vop-coding-type.patch
> From 026b0e88949a9c271b29e258f801ef1a902bf88c Mon Sep 17 00:00:00 2001
> From: Anuj Mittal <am.devel at gmail.com>
> Date: Tue, 9 Oct 2012 12:07:08 +0530
> Subject: [PATCH 2/2] Check for the resync_marker based on vop coding
>  type-vop_fcode_forward and vop_fcode_backward.
> 
> ---
>  lib/ffmpeg/libavcodec/ituh263dec.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/ffmpeg/libavcodec/ituh263dec.c b/lib/ffmpeg/libavcodec/ituh263dec.c
> index 4678287..bb8ca56 100644

> --- a/lib/ffmpeg/libavcodec/ituh263dec.c
> +++ b/lib/ffmpeg/libavcodec/ituh263dec.c

these patches dont apply cleanly with "git am"



> @@ -217,10 +217,11 @@ const uint8_t *ff_h263_find_resync_marker(MpegEncContext *s, const uint8_t *rest
>      end-=2;
>      p++;
>      if(s->resync_marker){

> +        int f_code = ff_mpeg4_get_video_packet_prefix_length(s);

this is the prefix length and not the f code


>          for(;p<end; p+=2){
>              if(!*p){
> -                if     (!p[-1] && p[1]) return p - 1;
> -                else if(!p[ 1] && p[2]) return p;
> +                if      (!p[-1] && ((p[1] >> (f_code-9)) == 1)) return p - 1;
> +                else if (!p[ 1] && ((p[2] >> (f_code-9)) == 1)) return p;

if the prefix length is > 16  this would do (byte >> 8) == 1 or rather
0 == 1

also please make sure the code is tested with a file that does have
resync markers

thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- 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/20121009/bac1d010/attachment.asc>


More information about the ffmpeg-devel mailing list