History

avcodec/evc_parse: remove ff_evc_parse_nal_unit()

James Almer committed 3 years ago

Commit 5cb9ef91 parent 56e52e83 files · +7 −224Browse files

Showing the changes to libavcodec (3 of 3 files). Show all

Unified · Split

3 files
  1. libavcodec/evc_parse.c +0 −182
  2. libavcodec/evc_parse.h +0 −42
  3. libavcodec/evc_parser.c +7 −0
libavcodec/evc_parse.c+0−182
@@ -21,32 +21,6 @@ · 20 unmodified lines
2121 #include "evc.h"
2222 #include "evc_parse.h"
2323
24−#define NUM_CHROMA_FORMATS 4 // @see ISO_IEC_23094-1 section 6.2 table 2
25−
26−static const enum AVPixelFormat pix_fmts_8bit[NUM_CHROMA_FORMATS] = {
27− AV_PIX_FMT_GRAY8, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P
28−};
29−
30−static const enum AVPixelFormat pix_fmts_9bit[NUM_CHROMA_FORMATS] = {
31− AV_PIX_FMT_GRAY9, AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9
32−};
33−
34−static const enum AVPixelFormat pix_fmts_10bit[NUM_CHROMA_FORMATS] = {
35− AV_PIX_FMT_GRAY10, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10
36−};
37−
38−static const enum AVPixelFormat pix_fmts_12bit[NUM_CHROMA_FORMATS] = {
39− AV_PIX_FMT_GRAY12, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12
40−};
41−
42−static const enum AVPixelFormat pix_fmts_14bit[NUM_CHROMA_FORMATS] = {
43− AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14
44−};
45−
46−static const enum AVPixelFormat pix_fmts_16bit[NUM_CHROMA_FORMATS] = {
47− AV_PIX_FMT_GRAY16, AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16
48−};
49−
5024 // nuh_temporal_id specifies a temporal identifier for the NAL unit
5125 int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx)
5226 {
@@ -258,159 +232,3 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, · 205 unmodified lines
258232
259233 return 0;
260234 }
261−
262−int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx)
263−{
264− int nalu_type, nalu_size;
265− int tid;
266− const uint8_t *data = buf;
267− int data_size = buf_size;
268−
269− // ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
270− ctx->key_frame = -1;
271−
272− nalu_size = buf_size;
273− if (nalu_size <= 0) {
274− av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", nalu_size);
275− return AVERROR_INVALIDDATA;
276− }
277−
278− // @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)
279− // @see enum EVCNALUnitType in evc.h
280− nalu_type = evc_get_nalu_type(data, data_size, logctx);
281− if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) {
282− av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", nalu_type);
283− return AVERROR_INVALIDDATA;
284− }
285− ctx->nalu_type = nalu_type;
286−
287− tid = ff_evc_get_temporal_id(data, data_size, logctx);
288− if (tid < 0) {
289− av_log(logctx, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid);
290− return AVERROR_INVALIDDATA;
291− }
292− ctx->nuh_temporal_id = tid;
293−
294− data += EVC_NALU_HEADER_SIZE;
295− data_size -= EVC_NALU_HEADER_SIZE;
296−
297− switch(nalu_type) {
298− case EVC_SPS_NUT: {
299− EVCParserSPS *sps;
300− int bit_depth;
301−
302− sps = ff_evc_parse_sps(&ctx->ps, data, nalu_size);
303− if (!sps) {
304− av_log(logctx, AV_LOG_ERROR, "SPS parsing error\n");
305− return AVERROR_INVALIDDATA;
306− }
307−
308− ctx->coded_width = sps->pic_width_in_luma_samples;
309− ctx->coded_height = sps->pic_height_in_luma_samples;
310−
311− if(sps->picture_cropping_flag) {
312− ctx->width = sps->pic_width_in_luma_samples - sps->picture_crop_left_offset - sps->picture_crop_right_offset;
313− ctx->height = sps->pic_height_in_luma_samples - sps->picture_crop_top_offset - sps->picture_crop_bottom_offset;
314− } else {
315− ctx->width = sps->pic_width_in_luma_samples;
316− ctx->height = sps->pic_height_in_luma_samples;
317− }
318−
319− if (sps->profile_idc == 1) ctx->profile = FF_PROFILE_EVC_MAIN;
320− else ctx->profile = FF_PROFILE_EVC_BASELINE;
321−
322− if (sps->vui_parameters_present_flag && sps->vui_parameters.timing_info_present_flag) {
323− int64_t num = sps->vui_parameters.num_units_in_tick;
324− int64_t den = sps->vui_parameters.time_scale;
325− if (num != 0 && den != 0)
326− av_reduce(&ctx->framerate.den, &ctx->framerate.num, num, den, 1 << 30);
327− } else
328− ctx->framerate = (AVRational) { 0, 1 };
329−
330− bit_depth = sps->bit_depth_chroma_minus8 + 8;
331− ctx->format = AV_PIX_FMT_NONE;
332−
333− switch (bit_depth) {
334− case 8:
335− ctx->format = pix_fmts_8bit[sps->chroma_format_idc];
336− break;
337− case 9:
338− ctx->format = pix_fmts_9bit[sps->chroma_format_idc];
339− break;
340− case 10:
341− ctx->format = pix_fmts_10bit[sps->chroma_format_idc];
342− break;
343− case 12:
344− ctx->format = pix_fmts_12bit[sps->chroma_format_idc];
345− break;
346− case 14:
347− ctx->format = pix_fmts_14bit[sps->chroma_format_idc];
348− break;
349− case 16:
350− ctx->format = pix_fmts_16bit[sps->chroma_format_idc];
351− break;
352− }
353− av_assert0(ctx->format != AV_PIX_FMT_NONE);
354−
355− break;
356− }
357− case EVC_PPS_NUT: {
358− EVCParserPPS *pps;
359−
360− pps = ff_evc_parse_pps(&ctx->ps, data, nalu_size);
361− if (!pps) {
362− av_log(logctx, AV_LOG_ERROR, "PPS parsing error\n");
363− return AVERROR_INVALIDDATA;
364− }
365− break;
366− }
367− case EVC_SEI_NUT: // Supplemental Enhancement Information
368− case EVC_APS_NUT: // Adaptation parameter set
369− case EVC_FD_NUT: // Filler data
370− break;
371− case EVC_IDR_NUT: // Coded slice of a IDR or non-IDR picture
372− case EVC_NOIDR_NUT: {
373− EVCParserSliceHeader sh;
374− int ret;
375−
376− ret = ff_evc_parse_slice_header(&sh, &ctx->ps, nalu_type, data, nalu_size);
377− if (ret < 0) {
378− av_log(logctx, AV_LOG_ERROR, "Slice header parsing error\n");
379− return ret;
380− }
381−
382− switch (sh.slice_type) {
383− case EVC_SLICE_TYPE_B: {
384− ctx->pict_type = AV_PICTURE_TYPE_B;
385− break;
386− }
387− case EVC_SLICE_TYPE_P: {
388− ctx->pict_type = AV_PICTURE_TYPE_P;
389− break;
390− }
391− case EVC_SLICE_TYPE_I: {
392− ctx->pict_type = AV_PICTURE_TYPE_I;
393− break;
394− }
395− default: {
396− ctx->pict_type = AV_PICTURE_TYPE_NONE;
397− }
398− }
399−
400− ctx->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0;
401−
402− // POC (picture order count of the current picture) derivation
403− // @see ISO/IEC 23094-1:2020(E) 8.3.1 Decoding process for picture order count
404− ret = ff_evc_derive_poc(&ctx->ps, &sh, &ctx->poc, nalu_type, tid);
405− if (ret < 0)
406− return ret;
407−
408− ctx->output_picture_number = ctx->poc.PicOrderCntVal;
409− ctx->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0;
410−
411− break;
412− }
413− }
414−
415− return 0;
416−}
libavcodec/evc_parse.h+0−42
@@ -81,46 +81,6 @@ typedef struct EVCParserPoc { · 80 unmodified lines
8181 int DocOffset; // the decoding order count of the previous picture
8282 } EVCParserPoc;
8383
84−typedef struct EVCParserContext {
85− EVCParamSets ps;
86− EVCParserPoc poc;
87−
88− int nuh_temporal_id; // the value of TemporalId (shall be the same for all VCL NAL units of an Access Unit)
89− int nalu_type; // the current NALU type
90−
91− // Dimensions of the decoded video intended for presentation.
92− int width;
93− int height;
94−
95− // Dimensions of the coded video.
96− int coded_width;
97− int coded_height;
98−
99− // The format of the coded data, corresponds to enum AVPixelFormat
100− int format;
101−
102− // AV_PICTURE_TYPE_I, EVC_SLICE_TYPE_P, AV_PICTURE_TYPE_B
103− int pict_type;
104−
105− // Set by parser to 1 for key frames and 0 for non-key frames
106− int key_frame;
107−
108− // Picture number incremented in presentation or output order.
109− // This corresponds to EVCEVCParserPoc::PicOrderCntVal
110− int output_picture_number;
111−
112− // profile
113− // 0: FF_PROFILE_EVC_BASELINE
114− // 1: FF_PROFILE_EVC_MAIN
115− int profile;
116−
117− // Framerate value in the compressed bitstream
118− AVRational framerate;
119−
120− int parsed_extradata;
121−
122−} EVCParserContext;
123−
12484 static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size, void *logctx)
12585 {
12686 int unit_type_plus1 = 0;
@@ -157,8 +117,6 @@ static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_si · 30 unmodified lines
157117 // nuh_temporal_id specifies a temporal identifier for the NAL unit
158118 int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx);
159119
160−int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx);
161−
162120 int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps,
163121 enum EVCNALUnitType nalu_type, const uint8_t *buf, int buf_size);
164122
libavcodec/evc_parser.c+7−0
@@ -25,6 +25,13 @@ · 24 unmodified lines
2525 #include "evc.h"
2626 #include "evc_parse.h"
2727
28+typedef struct EVCParserContext {
29+ EVCParamSets ps;
30+ EVCParserPoc poc;
31+
32+ int parsed_extradata;
33+} EVCParserContext;
34+
2835 #define NUM_CHROMA_FORMATS 4 // @see ISO_IEC_23094-1 section 6.2 table 2
2936
3037 static const enum AVPixelFormat pix_fmts_8bit[NUM_CHROMA_FORMATS] = {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t