[FFmpeg-devel] [PATCH] avcodec/hevc_parser: use ff_hevc_decode_extradata() to parse extradata

James Almer jamrial at gmail.com
Sat Jan 20 20:00:50 EET 2018


On 1/20/2018 1:12 AM, James Almer wrote:
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  libavcodec/hevc_parser.c | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
> index ff7e8a49d6..a3a9098c7c 100644
> --- a/libavcodec/hevc_parser.c
> +++ b/libavcodec/hevc_parser.c
> @@ -24,6 +24,7 @@
>  
>  #include "golomb.h"
>  #include "hevc.h"
> +#include "hevc_parse.h"
>  #include "hevc_ps.h"
>  #include "hevc_sei.h"
>  #include "h2645_parse.h"
> @@ -43,6 +44,8 @@ typedef struct HEVCParserContext {
>      HEVCSEI sei;
>      SliceHeader sh;
>  
> +    int is_avc;
> +    int nal_length_size;
>      int parsed_extradata;
>  
>      int poc;
> @@ -181,7 +184,6 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
>      HEVCParserContext *ctx = s->priv_data;
>      HEVCParamSets *ps = &ctx->ps;
>      HEVCSEI *sei = &ctx->sei;
> -    int is_global = buf == avctx->extradata;
>      int ret, i;
>  
>      /* set some sane default values */
> @@ -191,8 +193,8 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
>  
>      ff_hevc_reset_sei(sei);
>  
> -    ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0,
> -                                AV_CODEC_ID_HEVC, 1);
> +    ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, ctx->is_avc,
> +                                ctx->nal_length_size, AV_CODEC_ID_HEVC, 1);
>      if (ret < 0)
>          return ret;
>  
> @@ -230,12 +232,6 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
>          case HEVC_NAL_RADL_R:
>          case HEVC_NAL_RASL_N:
>          case HEVC_NAL_RASL_R:
> -
> -            if (is_global) {
> -                av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type);
> -                return AVERROR_INVALIDDATA;
> -            }
> -
>              ret = hevc_parse_slice_header(s, nal, avctx);
>              if (ret)
>                  return ret;
> @@ -243,8 +239,7 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
>          }
>      }
>      /* didn't find a picture! */
> -    if (!is_global)
> -        av_log(avctx, AV_LOG_ERROR, "missing picture in access unit\n");
> +    av_log(avctx, AV_LOG_ERROR, "missing picture in access unit\n");
>      return -1;
>  }
>  
> @@ -301,7 +296,9 @@ static int hevc_parse(AVCodecParserContext *s, AVCodecContext *avctx,
>      ParseContext *pc = &ctx->pc;
>  
>      if (avctx->extradata && !ctx->parsed_extradata) {
> -        parse_nal_units(s, avctx->extradata, avctx->extradata_size, avctx);
> +        ff_hevc_decode_extradata(buf, buf_size, &ctx->ps, &ctx->sei, &ctx->is_avc,

Changed buf and buf_size locally to avctx->extradata and
avctx->extradata_size.

> +                                 &ctx->nal_length_size, avctx->err_recognition,
> +                                 1, avctx);
>          ctx->parsed_extradata = 1;
>      }
>  
> 



More information about the ffmpeg-devel mailing list