This is in preparation for the following commits.
Showing the changes to libavcodec (3 of 3 files). Show all
Unified · Split
| @@ -70,11 +70,12 @@ int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx) · 69 unmodified lines | |||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | // @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax) | 72 | // @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax) |
| 73 | static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *sh, const uint8_t *bs, int bs_size) | 73 | int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps, |
| 74 | enum EVCNALUnitType nalu_type, const uint8_t *bs, int bs_size) | ||
| 74 | { | 75 | { |
| 75 | GetBitContext gb; | 76 | GetBitContext gb; |
| 76 | EVCParserPPS *pps; | 77 | const EVCParserPPS *pps; |
| 77 | EVCParserSPS *sps; | 78 | const EVCParserSPS *sps; |
| 78 | 79 | ||
| 79 | int num_tiles_in_slice = 0; | 80 | int num_tiles_in_slice = 0; |
| 80 | int slice_pic_parameter_set_id; | 81 | int slice_pic_parameter_set_id; |
| @@ -88,11 +89,11 @@ static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *s · 7 unmodified lines | |||
| 88 | if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= EVC_MAX_PPS_COUNT) | 89 | if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= EVC_MAX_PPS_COUNT) |
| 89 | return AVERROR_INVALIDDATA; | 90 | return AVERROR_INVALIDDATA; |
| 90 | 91 | ||
| 91 | pps = ctx->ps.pps[slice_pic_parameter_set_id]; | 92 | pps = ps->pps[slice_pic_parameter_set_id]; |
| 92 | if(!pps) | 93 | if(!pps) |
| 93 | return AVERROR_INVALIDDATA; | 94 | return AVERROR_INVALIDDATA; |
| 94 | 95 | ||
| 95 | sps = ctx->ps.sps[pps->pps_seq_parameter_set_id]; | 96 | sps = ps->sps[pps->pps_seq_parameter_set_id]; |
| 96 | if(!sps) | 97 | if(!sps) |
| 97 | return AVERROR_INVALIDDATA; | 98 | return AVERROR_INVALIDDATA; |
| 98 | 99 | ||
| @@ -121,7 +122,7 @@ static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *s · 22 unmodified lines | |||
| 121 | 122 | ||
| 122 | sh->slice_type = get_ue_golomb(&gb); | 123 | sh->slice_type = get_ue_golomb(&gb); |
| 123 | 124 | ||
| 124 | if (ctx->nalu_type == EVC_IDR_NUT) | 125 | if (nalu_type == EVC_IDR_NUT) |
| 125 | sh->no_output_of_prior_pics_flag = get_bits(&gb, 1); | 126 | sh->no_output_of_prior_pics_flag = get_bits(&gb, 1); |
| 126 | 127 | ||
| 127 | if (sps->sps_mmvd_flag && ((sh->slice_type == EVC_SLICE_TYPE_B) || (sh->slice_type == EVC_SLICE_TYPE_P))) | 128 | if (sps->sps_mmvd_flag && ((sh->slice_type == EVC_SLICE_TYPE_B) || (sh->slice_type == EVC_SLICE_TYPE_P))) |
| @@ -175,7 +176,7 @@ static int evc_parse_slice_header(EVCParserContext *ctx, EVCParserSliceHeader *s · 47 unmodified lines | |||
| 175 | } | 176 | } |
| 176 | } | 177 | } |
| 177 | 178 | ||
| 178 | if (ctx->nalu_type != EVC_IDR_NUT) { | 179 | if (nalu_type != EVC_IDR_NUT) { |
| 179 | if (sps->sps_pocs_flag) | 180 | if (sps->sps_pocs_flag) |
| 180 | sh->slice_pic_order_cnt_lsb = get_bits(&gb, sps->log2_max_pic_order_cnt_lsb_minus4 + 4); | 181 | sh->slice_pic_order_cnt_lsb = get_bits(&gb, sps->log2_max_pic_order_cnt_lsb_minus4 + 4); |
| 181 | } | 182 | } |
| @@ -372,7 +373,7 @@ int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_siz · 190 unmodified lines | |||
| 372 | EVCParserSliceHeader sh; | 373 | EVCParserSliceHeader sh; |
| 373 | int ret; | 374 | int ret; |
| 374 | 375 | ||
| 375 | ret = evc_parse_slice_header(ctx, &sh, data, nalu_size); | 376 | ret = ff_evc_parse_slice_header(&sh, &ctx->ps, nalu_type, data, nalu_size); |
| 376 | if (ret < 0) { | 377 | if (ret < 0) { |
| 377 | av_log(logctx, AV_LOG_ERROR, "Slice header parsing error\n"); | 378 | av_log(logctx, AV_LOG_ERROR, "Slice header parsing error\n"); |
| 378 | return ret; | 379 | return ret; |
| @@ -159,6 +159,9 @@ int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx); · 158 unmodified lines | |||
| 159 | 159 | ||
| 160 | int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx); | 160 | int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx); |
| 161 | 161 | ||
| 162 | int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps, | ||
| 163 | enum EVCNALUnitType nalu_type, const uint8_t *buf, int buf_size); | ||
| 164 | |||
| 162 | // POC (picture order count of the current picture) derivation | 165 | // POC (picture order count of the current picture) derivation |
| 163 | // @see ISO/IEC 23094-1:2020(E) 8.3.1 Decoding process for picture order count | 166 | // @see ISO/IEC 23094-1:2020(E) 8.3.1 Decoding process for picture order count |
| 164 | int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, | 167 | int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, |
| @@ -25,6 +25,180 @@ · 24 unmodified lines | |||
| 25 | #include "evc.h" | 25 | #include "evc.h" |
| 26 | #include "evc_parse.h" | 26 | #include "evc_parse.h" |
| 27 | 27 | ||
| 28 | #define NUM_CHROMA_FORMATS 4 // @see ISO_IEC_23094-1 section 6.2 table 2 | ||
| 29 | |||
| 30 | static const enum AVPixelFormat pix_fmts_8bit[NUM_CHROMA_FORMATS] = { | ||
| 31 | AV_PIX_FMT_GRAY8, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P | ||
| 32 | }; | ||
| 33 | |||
| 34 | static const enum AVPixelFormat pix_fmts_9bit[NUM_CHROMA_FORMATS] = { | ||
| 35 | AV_PIX_FMT_GRAY9, AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9 | ||
| 36 | }; | ||
| 37 | |||
| 38 | static const enum AVPixelFormat pix_fmts_10bit[NUM_CHROMA_FORMATS] = { | ||
| 39 | AV_PIX_FMT_GRAY10, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10 | ||
| 40 | }; | ||
| 41 | |||
| 42 | static const enum AVPixelFormat pix_fmts_12bit[NUM_CHROMA_FORMATS] = { | ||
| 43 | AV_PIX_FMT_GRAY12, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12 | ||
| 44 | }; | ||
| 45 | |||
| 46 | static const enum AVPixelFormat pix_fmts_14bit[NUM_CHROMA_FORMATS] = { | ||
| 47 | AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14 | ||
| 48 | }; | ||
| 49 | |||
| 50 | static const enum AVPixelFormat pix_fmts_16bit[NUM_CHROMA_FORMATS] = { | ||
| 51 | AV_PIX_FMT_GRAY16, AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16 | ||
| 52 | }; | ||
| 53 | |||
| 54 | static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx, | ||
| 55 | const uint8_t *buf, int buf_size) | ||
| 56 | { | ||
| 57 | EVCParserContext *ctx = s->priv_data; | ||
| 58 | int nalu_type, tid; | ||
| 59 | |||
| 60 | if (buf_size <= 0) { | ||
| 61 | av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", buf_size); | ||
| 62 | return AVERROR_INVALIDDATA; | ||
| 63 | } | ||
| 64 | |||
| 65 | // @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic (Table 4 - NAL unit type codes and NAL unit type classes) | ||
| 66 | // @see enum EVCNALUnitType in evc.h | ||
| 67 | nalu_type = evc_get_nalu_type(buf, buf_size, avctx); | ||
| 68 | if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) { | ||
| 69 | av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", nalu_type); | ||
| 70 | return AVERROR_INVALIDDATA; | ||
| 71 | } | ||
| 72 | |||
| 73 | tid = ff_evc_get_temporal_id(buf, buf_size, avctx); | ||
| 74 | if (tid < 0) { | ||
| 75 | av_log(avctx, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid); | ||
| 76 | return AVERROR_INVALIDDATA; | ||
| 77 | } | ||
| 78 | |||
| 79 | buf += EVC_NALU_HEADER_SIZE; | ||
| 80 | buf_size -= EVC_NALU_HEADER_SIZE; | ||
| 81 | |||
| 82 | switch (nalu_type) { | ||
| 83 | case EVC_SPS_NUT: { | ||
| 84 | EVCParserSPS *sps = ff_evc_parse_sps(&ctx->ps, buf, buf_size); | ||
| 85 | if (!sps) { | ||
| 86 | av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n"); | ||
| 87 | return AVERROR_INVALIDDATA; | ||
| 88 | } | ||
| 89 | break; | ||
| 90 | } | ||
| 91 | case EVC_PPS_NUT: { | ||
| 92 | EVCParserPPS *pps = ff_evc_parse_pps(&ctx->ps, buf, buf_size); | ||
| 93 | if (!pps) { | ||
| 94 | av_log(avctx, AV_LOG_ERROR, "PPS parsing error\n"); | ||
| 95 | return AVERROR_INVALIDDATA; | ||
| 96 | } | ||
| 97 | break; | ||
| 98 | } | ||
| 99 | case EVC_IDR_NUT: // Coded slice of a IDR or non-IDR picture | ||
| 100 | case EVC_NOIDR_NUT: { | ||
| 101 | const EVCParserPPS *pps; | ||
| 102 | const EVCParserSPS *sps; | ||
| 103 | EVCParserSliceHeader sh; | ||
| 104 | int bit_depth; | ||
| 105 | int ret; | ||
| 106 | |||
| 107 | ret = ff_evc_parse_slice_header(&sh, &ctx->ps, nalu_type, buf, buf_size); | ||
| 108 | if (ret < 0) { | ||
| 109 | av_log(avctx, AV_LOG_ERROR, "Slice header parsing error\n"); | ||
| 110 | return ret; | ||
| 111 | } | ||
| 112 | |||
| 113 | pps = ctx->ps.pps[sh.slice_pic_parameter_set_id]; | ||
| 114 | sps = ctx->ps.sps[pps->pps_seq_parameter_set_id]; | ||
| 115 | av_assert0(sps && pps); | ||
| 116 | |||
| 117 | s->coded_width = sps->pic_width_in_luma_samples; | ||
| 118 | s->coded_height = sps->pic_height_in_luma_samples; | ||
| 119 | |||
| 120 | if (sps->picture_cropping_flag) { | ||
| 121 | s->width = sps->pic_width_in_luma_samples - sps->picture_crop_left_offset - sps->picture_crop_right_offset; | ||
| 122 | s->height = sps->pic_height_in_luma_samples - sps->picture_crop_top_offset - sps->picture_crop_bottom_offset; | ||
| 123 | } else { | ||
| 124 | s->width = sps->pic_width_in_luma_samples; | ||
| 125 | s->height = sps->pic_height_in_luma_samples; | ||
| 126 | } | ||
| 127 | |||
| 128 | switch (sh.slice_type) { | ||
| 129 | case EVC_SLICE_TYPE_B: { | ||
| 130 | s->pict_type = AV_PICTURE_TYPE_B; | ||
| 131 | break; | ||
| 132 | } | ||
| 133 | case EVC_SLICE_TYPE_P: { | ||
| 134 | s->pict_type = AV_PICTURE_TYPE_P; | ||
| 135 | break; | ||
| 136 | } | ||
| 137 | case EVC_SLICE_TYPE_I: { | ||
| 138 | s->pict_type = AV_PICTURE_TYPE_I; | ||
| 139 | break; | ||
| 140 | } | ||
| 141 | default: { | ||
| 142 | s->pict_type = AV_PICTURE_TYPE_NONE; | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | avctx->profile = sps->profile_idc; | ||
| 147 | |||
| 148 | if (sps->vui_parameters_present_flag && sps->vui_parameters.timing_info_present_flag) { | ||
| 149 | int64_t num = sps->vui_parameters.num_units_in_tick; | ||
| 150 | int64_t den = sps->vui_parameters.time_scale; | ||
| 151 | if (num != 0 && den != 0) | ||
| 152 | av_reduce(&avctx->framerate.den, &avctx->framerate.num, num, den, 1 << 30); | ||
| 153 | } else | ||
| 154 | avctx->framerate = (AVRational) { 0, 1 }; | ||
| 155 | |||
| 156 | bit_depth = sps->bit_depth_chroma_minus8 + 8; | ||
| 157 | s->format = AV_PIX_FMT_NONE; | ||
| 158 | |||
| 159 | switch (bit_depth) { | ||
| 160 | case 8: | ||
| 161 | s->format = pix_fmts_8bit[sps->chroma_format_idc]; | ||
| 162 | break; | ||
| 163 | case 9: | ||
| 164 | s->format = pix_fmts_9bit[sps->chroma_format_idc]; | ||
| 165 | break; | ||
| 166 | case 10: | ||
| 167 | s->format = pix_fmts_10bit[sps->chroma_format_idc]; | ||
| 168 | break; | ||
| 169 | case 12: | ||
| 170 | s->format = pix_fmts_12bit[sps->chroma_format_idc]; | ||
| 171 | break; | ||
| 172 | case 14: | ||
| 173 | s->format = pix_fmts_14bit[sps->chroma_format_idc]; | ||
| 174 | break; | ||
| 175 | case 16: | ||
| 176 | s->format = pix_fmts_16bit[sps->chroma_format_idc]; | ||
| 177 | break; | ||
| 178 | } | ||
| 179 | |||
| 180 | s->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0; | ||
| 181 | |||
| 182 | // POC (picture order count of the current picture) derivation | ||
| 183 | // @see ISO/IEC 23094-1:2020(E) 8.3.1 Decoding process for picture order count | ||
| 184 | ret = ff_evc_derive_poc(&ctx->ps, &sh, &ctx->poc, nalu_type, tid); | ||
| 185 | if (ret < 0) | ||
| 186 | return ret; | ||
| 187 | |||
| 188 | s->output_picture_number = ctx->poc.PicOrderCntVal; | ||
| 189 | |||
| 190 | break; | ||
| 191 | } | ||
| 192 | case EVC_SEI_NUT: // Supplemental Enhancement Information | ||
| 193 | case EVC_APS_NUT: // Adaptation parameter set | ||
| 194 | case EVC_FD_NUT: // Filler data | ||
| 195 | default: | ||
| 196 | break; | ||
| 197 | } | ||
| 198 | |||
| 199 | return 0; | ||
| 200 | } | ||
| 201 | |||
| 28 | /** | 202 | /** |
| 29 | * Parse NAL units of found picture and decode some basic information. | 203 | * Parse NAL units of found picture and decode some basic information. |
| 30 | * | 204 | * |
| @@ -35,13 +209,13 @@ · 4 unmodified lines | |||
| 35 | */ | 209 | */ |
| 36 | static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *buf, int buf_size) | 210 | static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t *buf, int buf_size) |
| 37 | { | 211 | { |
| 38 | EVCParserContext *ctx = s->priv_data; | ||
| 39 | const uint8_t *data = buf; | 212 | const uint8_t *data = buf; |
| 40 | int data_size = buf_size; | 213 | int data_size = buf_size; |
| 41 | int bytes_read = 0; | 214 | int bytes_read = 0; |
| 42 | int nalu_size = 0; | ||
| 43 | 215 | ||
| 44 | while (data_size > 0) { | 216 | while (data_size > 0) { |
| 217 | int nalu_size = 0; | ||
| 218 | int ret; | ||
| 45 | 219 | ||
| 46 | // Buffer size is not enough for buffer to store NAL unit 4-bytes prefix (length) | 220 | // Buffer size is not enough for buffer to store NAL unit 4-bytes prefix (length) |
| 47 | if (data_size < EVC_NALU_LENGTH_PREFIX_SIZE) | 221 | if (data_size < EVC_NALU_LENGTH_PREFIX_SIZE) |
| @@ -57,31 +231,12 @@ static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const · 9 unmodified lines | |||
| 57 | if (data_size < nalu_size) | 231 | if (data_size < nalu_size) |
| 58 | return AVERROR_INVALIDDATA; | 232 | return AVERROR_INVALIDDATA; |
| 59 | 233 | ||
| 60 | if (ff_evc_parse_nal_unit(ctx, data, nalu_size, avctx) != 0) { | 234 | ret = parse_nal_unit(s, avctx, data, nalu_size); |
| 235 | if (ret < 0) { | ||
| 61 | av_log(avctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); | 236 | av_log(avctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); |
| 62 | return AVERROR_INVALIDDATA; | 237 | return AVERROR_INVALIDDATA; |
| 63 | } | 238 | } |
| 64 | 239 | ||
| 65 | if(ctx->nalu_type == EVC_SPS_NUT) { | ||
| 66 | |||
| 67 | s->coded_width = ctx->coded_width; | ||
| 68 | s->coded_height = ctx->coded_height; | ||
| 69 | s->width = ctx->width; | ||
| 70 | s->height = ctx->height; | ||
| 71 | |||
| 72 | s->format = ctx->format; | ||
| 73 | |||
| 74 | avctx->framerate = ctx->framerate; | ||
| 75 | avctx->profile = ctx->profile; | ||
| 76 | |||
| 77 | } else if(ctx->nalu_type == EVC_NOIDR_NUT || ctx->nalu_type == EVC_IDR_NUT) { | ||
| 78 | |||
| 79 | s->pict_type = ctx->pict_type; | ||
| 80 | s->key_frame = ctx->key_frame; | ||
| 81 | s->output_picture_number = ctx->output_picture_number; | ||
| 82 | |||
| 83 | } | ||
| 84 | |||
| 85 | data += nalu_size; | 240 | data += nalu_size; |
| 86 | data_size -= nalu_size; | 241 | data_size -= nalu_size; |
| 87 | } | 242 | } |
| @@ -90,8 +245,10 @@ static int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx, const · 2 unmodified lines | |||
| 90 | 245 | ||
| 91 | // Decoding nal units from evcC (EVCDecoderConfigurationRecord) | 246 | // Decoding nal units from evcC (EVCDecoderConfigurationRecord) |
| 92 | // @see @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.2 | 247 | // @see @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.2 |
| 93 | static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size, void *logctx) | 248 | static int decode_extradata(AVCodecParserContext *s, AVCodecContext *avctx) |
| 94 | { | 249 | { |
| 250 | const uint8_t *data = avctx->extradata; | ||
| 251 | int size = avctx->extradata_size; | ||
| 95 | int ret = 0; | 252 | int ret = 0; |
| 96 | GetByteContext gb; | 253 | GetByteContext gb; |
| 97 | 254 | ||
| @@ -108,7 +265,7 @@ static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size · 10 unmodified lines | |||
| 108 | // The value of this field shall be one of 0, 1, or 3 corresponding to a length encoded with 1, 2, or 4 bytes, respectively. | 265 | // The value of this field shall be one of 0, 1, or 3 corresponding to a length encoded with 1, 2, or 4 bytes, respectively. |
| 109 | 266 | ||
| 110 | if (bytestream2_get_bytes_left(&gb) < 18) { | 267 | if (bytestream2_get_bytes_left(&gb) < 18) { |
| 111 | av_log(logctx, AV_LOG_ERROR, "evcC %d too short\n", size); | 268 | av_log(avctx, AV_LOG_ERROR, "evcC %d too short\n", size); |
| 112 | return AVERROR_INVALIDDATA; | 269 | return AVERROR_INVALIDDATA; |
| 113 | } | 270 | } |
| 114 | 271 | ||
| @@ -121,7 +278,7 @@ static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size · 6 unmodified lines | |||
| 121 | if( nalu_length_field_size != 1 && | 278 | if( nalu_length_field_size != 1 && |
| 122 | nalu_length_field_size != 2 && | 279 | nalu_length_field_size != 2 && |
| 123 | nalu_length_field_size != 4 ) { | 280 | nalu_length_field_size != 4 ) { |
| 124 | av_log(logctx, AV_LOG_ERROR, "The length in bytes of the NALUnitLenght field in a EVC video stream has unsupported value of %d\n", nalu_length_field_size); | 281 | av_log(avctx, AV_LOG_ERROR, "The length in bytes of the NALUnitLenght field in a EVC video stream has unsupported value of %d\n", nalu_length_field_size); |
| 125 | return AVERROR_INVALIDDATA; | 282 | return AVERROR_INVALIDDATA; |
| 126 | } | 283 | } |
| 127 | 284 | ||
| @@ -142,7 +299,7 @@ static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size · 14 unmodified lines | |||
| 142 | int nal_unit_length = bytestream2_get_be16(&gb); | 299 | int nal_unit_length = bytestream2_get_be16(&gb); |
| 143 | 300 | ||
| 144 | if (bytestream2_get_bytes_left(&gb) < nal_unit_length) { | 301 | if (bytestream2_get_bytes_left(&gb) < nal_unit_length) { |
| 145 | av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit size in extradata.\n"); | 302 | av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size in extradata.\n"); |
| 146 | return AVERROR_INVALIDDATA; | 303 | return AVERROR_INVALIDDATA; |
| 147 | } | 304 | } |
| 148 | 305 | ||
| @@ -150,8 +307,8 @@ static int decode_extradata(EVCParserContext *ctx, const uint8_t *data, int size · 1 unmodified line | |||
| 150 | nal_unit_type == EVC_PPS_NUT || | 307 | nal_unit_type == EVC_PPS_NUT || |
| 151 | nal_unit_type == EVC_APS_NUT || | 308 | nal_unit_type == EVC_APS_NUT || |
| 152 | nal_unit_type == EVC_SEI_NUT ) { | 309 | nal_unit_type == EVC_SEI_NUT ) { |
| 153 | if (ff_evc_parse_nal_unit(ctx, gb.buffer, nal_unit_length, logctx) != 0) { | 310 | if (parse_nal_unit(s, avctx, gb.buffer, nal_unit_length) != 0) { |
| 154 | av_log(logctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); | 311 | av_log(avctx, AV_LOG_ERROR, "Parsing of NAL unit failed\n"); |
| 155 | return AVERROR_INVALIDDATA; | 312 | return AVERROR_INVALIDDATA; |
| 156 | } | 313 | } |
| 157 | } | 314 | } |
| @@ -173,8 +330,11 @@ static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx, · 15 unmodified lines | |||
| 173 | int ret; | 330 | int ret; |
| 174 | EVCParserContext *ctx = s->priv_data; | 331 | EVCParserContext *ctx = s->priv_data; |
| 175 | 332 | ||
| 333 | s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; | ||
| 334 | s->key_frame = 0; | ||
| 335 | |||
| 176 | if (avctx->extradata && !ctx->parsed_extradata) { | 336 | if (avctx->extradata && !ctx->parsed_extradata) { |
| 177 | decode_extradata(ctx, avctx->extradata, avctx->extradata_size, avctx); | 337 | decode_extradata(s, avctx); |
| 178 | ctx->parsed_extradata = 1; | 338 | ctx->parsed_extradata = 1; |
| 179 | } | 339 | } |
| 180 | 340 | ||
| @@ -187,8 +347,6 @@ static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx, · 6 unmodified lines | |||
| 187 | return buf_size; | 347 | return buf_size; |
| 188 | } | 348 | } |
| 189 | 349 | ||
| 190 | s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; | ||
| 191 | |||
| 192 | // poutbuf contains just one Access Unit | 350 | // poutbuf contains just one Access Unit |
| 193 | *poutbuf = buf; | 351 | *poutbuf = buf; |
| 194 | *poutbuf_size = buf_size; | 352 | *poutbuf_size = buf_size; |