[FFmpeg-devel] [PATCH, v2] lavc/hevc_parser: add 4 bytes startcode condition and update FATE

Fu, Linjie linjie.fu at intel.com
Mon Dec 10 12:30:15 EET 2018


> -----Original Message-----
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Monday, December 10, 2018 01:40
> To: ffmpeg-devel at ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/hevc_parser: add 4 bytes
> startcode condition and update FATE
> 
> >
> >  #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes
> > +#define START_CODE_4 0x00000001 ///< start_code_4bytes
> 
> (There is no syntax element called "start_code_4bytes".)
> 
Deleted.
> >
> >  #define IS_IRAP_NAL(nal) (nal->type >= 16 && nal->type <= 23)
> >  #define IS_IDR_NAL(nal) (nal->type == HEVC_NAL_IDR_W_RADL || nal-
> >type == HEVC_NAL_IDR_N_LP)
> > @@ -239,7 +240,7 @@ static int parse_nal_units(AVCodecParserContext *s,
> const uint8_t *buf,
> >          }
> >      }
> >      /* didn't find a picture! */
> > -    av_log(avctx, AV_LOG_ERROR, "missing picture in access unit\n");
> > +    av_log(avctx, AV_LOG_ERROR, "missing picture in access unit with
> size %d\n", buf_size);
> >      return -1;
> >  }
> >
> > @@ -267,8 +268,7 @@ static int
> hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf,
> >          if ((nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_EOB_NUT) || nut ==
> HEVC_NAL_SEI_PREFIX ||
> >              (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
> >              if (pc->frame_start_found) {
> > -                pc->frame_start_found = 0;
> > -                return i - 5;
> > +                goto found;
> >              }
> >          } else if (nut <= HEVC_NAL_RASL_R ||
> >                     (nut >= HEVC_NAL_BLA_W_LP && nut <= HEVC_NAL_CRA_NUT))
> {
> > @@ -277,14 +277,19 @@ static int
> hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf,
> >                  if (!pc->frame_start_found) {
> >                      pc->frame_start_found = 1;
> >                  } else { // First slice of next frame found
> > -                    pc->frame_start_found = 0;
> > -                    return i - 5;
> > +                    goto found;
> >                  }
> >              }
> >          }
> >      }
> >
> >      return END_NOT_FOUND;
> > +
> > +found:
> > +    pc->frame_start_found = 0;
> > +    if (((pc->state64 >> 3 * 8) & 0xFFFFFFFF) == START_CODE_4)
> > +        return i - 6;
> > +    return i - 5;
> >  }
> 
> Maybe?  Special-casing four bytes doesn't make me feel good about this,
> given that leading_zero_8bits can be included as many times as you like at
> the beginning of a NAL unit.
> 
> If there are a large number of zeroes between two frames, which packet do
> you want them to end up in?  This changes it from "all at the end of the first
> frame" to "all except the last one at the end of the first frame", and it's not
> immediately obvious to me why that would be the right choice.  Why not, for
> example, put all of the zeroes into the second frame?

Modified and sent a new patch to find all leading_zero_8bits and put them into 
the second frame.

Thanks
---
Linjie Fu


More information about the ffmpeg-devel mailing list