Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 10/10] avcodec/evc_parse: remove ff_evc_parse_nal_unit()
Date: Sat, 17 Jun 2023 19:00:15 -0300
Message-ID: <20230617220015.12669-7-jamrial@gmail.com> (raw)
In-Reply-To: <20230617151848.1378-1-jamrial@gmail.com>

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/evc_parse.c  | 156 ----------------------------------------
 libavcodec/evc_parse.h  |  42 -----------
 libavcodec/evc_parser.c |   7 ++
 3 files changed, 7 insertions(+), 198 deletions(-)

diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c
index 0ad0d82137..48bd3ce5e9 100644
--- a/libavcodec/evc_parse.c
+++ b/libavcodec/evc_parse.c
@@ -258,159 +258,3 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh,
 
     return 0;
 }
-
-int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx)
-{
-    int nalu_type, nalu_size;
-    int tid;
-    const uint8_t *data = buf;
-    int data_size = buf_size;
-
-    // ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
-    ctx->key_frame = -1;
-
-    nalu_size = buf_size;
-    if (nalu_size <= 0) {
-        av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", nalu_size);
-        return AVERROR_INVALIDDATA;
-    }
-
-    // @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)
-    // @see enum EVCNALUnitType in evc.h
-    nalu_type = evc_get_nalu_type(data, data_size, logctx);
-    if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) {
-        av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", nalu_type);
-        return AVERROR_INVALIDDATA;
-    }
-    ctx->nalu_type = nalu_type;
-
-    tid = ff_evc_get_temporal_id(data, data_size, logctx);
-    if (tid < 0) {
-        av_log(logctx, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid);
-        return AVERROR_INVALIDDATA;
-    }
-    ctx->nuh_temporal_id = tid;
-
-    data += EVC_NALU_HEADER_SIZE;
-    data_size -= EVC_NALU_HEADER_SIZE;
-
-    switch(nalu_type) {
-    case EVC_SPS_NUT: {
-        EVCParserSPS *sps;
-        int bit_depth;
-
-        sps = ff_evc_parse_sps(&ctx->ps, data, nalu_size);
-        if (!sps) {
-            av_log(logctx, AV_LOG_ERROR, "SPS parsing error\n");
-            return AVERROR_INVALIDDATA;
-        }
-
-        ctx->coded_width         = sps->pic_width_in_luma_samples;
-        ctx->coded_height        = sps->pic_height_in_luma_samples;
-
-        if(sps->picture_cropping_flag) {
-            ctx->width           = sps->pic_width_in_luma_samples  - sps->picture_crop_left_offset - sps->picture_crop_right_offset;
-            ctx->height          = sps->pic_height_in_luma_samples - sps->picture_crop_top_offset  - sps->picture_crop_bottom_offset;
-        } else {
-            ctx->width           = sps->pic_width_in_luma_samples;
-            ctx->height          = sps->pic_height_in_luma_samples;
-        }
-
-        if (sps->profile_idc == 1) ctx->profile = FF_PROFILE_EVC_MAIN;
-        else ctx->profile = FF_PROFILE_EVC_BASELINE;
-
-        if (sps->vui_parameters_present_flag && sps->vui_parameters.timing_info_present_flag) {
-            int64_t num = sps->vui_parameters.num_units_in_tick;
-            int64_t den = sps->vui_parameters.time_scale;
-            if (num != 0 && den != 0)
-                av_reduce(&ctx->framerate.den, &ctx->framerate.num, num, den, 1 << 30);
-        } else
-            ctx->framerate = (AVRational) { 0, 1 };
-
-        bit_depth = sps->bit_depth_chroma_minus8 + 8;
-        ctx->format = AV_PIX_FMT_NONE;
-
-        switch (bit_depth) {
-        case 8:
-            ctx->format = pix_fmts_8bit[sps->chroma_format_idc];
-            break;
-        case 9:
-            ctx->format = pix_fmts_9bit[sps->chroma_format_idc];
-            break;
-        case 10:
-            ctx->format = pix_fmts_10bit[sps->chroma_format_idc];
-            break;
-        case 12:
-            ctx->format = pix_fmts_12bit[sps->chroma_format_idc];
-            break;
-        case 14:
-            ctx->format = pix_fmts_14bit[sps->chroma_format_idc];
-            break;
-        case 16:
-            ctx->format = pix_fmts_16bit[sps->chroma_format_idc];
-            break;
-        }
-        av_assert0(ctx->format != AV_PIX_FMT_NONE);
-
-        break;
-    }
-    case EVC_PPS_NUT: {
-        EVCParserPPS *pps;
-
-        pps = ff_evc_parse_pps(&ctx->ps, data, nalu_size);
-        if (!pps) {
-            av_log(logctx, AV_LOG_ERROR, "PPS parsing error\n");
-            return AVERROR_INVALIDDATA;
-        }
-        break;
-    }
-    case EVC_SEI_NUT:   // Supplemental Enhancement Information
-    case EVC_APS_NUT:   // Adaptation parameter set
-    case EVC_FD_NUT:    // Filler data
-        break;
-    case EVC_IDR_NUT:   // Coded slice of a IDR or non-IDR picture
-    case EVC_NOIDR_NUT: {
-        EVCParserSliceHeader sh;
-        int ret;
-
-        ret = ff_evc_parse_slice_header(&sh, &ctx->ps, nalu_type, data, nalu_size);
-        if (ret < 0) {
-            av_log(logctx, AV_LOG_ERROR, "Slice header parsing error\n");
-            return ret;
-        }
-
-        switch (sh.slice_type) {
-        case EVC_SLICE_TYPE_B: {
-            ctx->pict_type =  AV_PICTURE_TYPE_B;
-            break;
-        }
-        case EVC_SLICE_TYPE_P: {
-            ctx->pict_type =  AV_PICTURE_TYPE_P;
-            break;
-        }
-        case EVC_SLICE_TYPE_I: {
-            ctx->pict_type =  AV_PICTURE_TYPE_I;
-            break;
-        }
-        default: {
-            ctx->pict_type =  AV_PICTURE_TYPE_NONE;
-        }
-        }
-
-        ctx->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0;
-
-        // POC (picture order count of the current picture) derivation
-        // @see ISO/IEC 23094-1:2020(E) 8.3.1 Decoding process for picture order count
-        ret = ff_evc_derive_poc(&ctx->ps, &sh, &ctx->poc, nalu_type, tid);
-        if (ret < 0)
-            return ret;
-
-        ctx->output_picture_number = ctx->poc.PicOrderCntVal;
-        ctx->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0;
-
-        break;
-    }
-    }
-
-    return 0;
-}
diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h
index f31075ff9c..a1fbbc643d 100644
--- a/libavcodec/evc_parse.h
+++ b/libavcodec/evc_parse.h
@@ -81,46 +81,6 @@ typedef struct EVCParserPoc {
     int DocOffset;          // the decoding order count of the previous picture
 } EVCParserPoc;
 
-typedef struct EVCParserContext {
-    EVCParamSets ps;
-    EVCParserPoc poc;
-
-    int nuh_temporal_id;            // the value of TemporalId (shall be the same for all VCL NAL units of an Access Unit)
-    int nalu_type;                  // the current NALU type
-
-    // Dimensions of the decoded video intended for presentation.
-    int width;
-    int height;
-
-    // Dimensions of the coded video.
-    int coded_width;
-    int coded_height;
-
-    // The format of the coded data, corresponds to enum AVPixelFormat
-    int format;
-
-    // AV_PICTURE_TYPE_I, EVC_SLICE_TYPE_P, AV_PICTURE_TYPE_B
-    int pict_type;
-
-    // Set by parser to 1 for key frames and 0 for non-key frames
-    int key_frame;
-
-    // Picture number incremented in presentation or output order.
-    // This corresponds to EVCEVCParserPoc::PicOrderCntVal
-    int output_picture_number;
-
-    // profile
-    // 0: FF_PROFILE_EVC_BASELINE
-    // 1: FF_PROFILE_EVC_MAIN
-    int profile;
-
-    // Framerate value in the compressed bitstream
-    AVRational framerate;
-
-    int parsed_extradata;
-
-} EVCParserContext;
-
 static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size, void *logctx)
 {
     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
 // nuh_temporal_id specifies a temporal identifier for the NAL unit
 int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx);
 
-int ff_evc_parse_nal_unit(EVCParserContext *ctx, const uint8_t *buf, int buf_size, void *logctx);
-
 int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps,
                               enum EVCNALUnitType nalu_type, const uint8_t *buf, int buf_size);
 
diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c
index c30da6846e..710fabccb2 100644
--- a/libavcodec/evc_parser.c
+++ b/libavcodec/evc_parser.c
@@ -25,6 +25,13 @@
 #include "evc.h"
 #include "evc_parse.h"
 
+typedef struct EVCParserContext {
+    EVCParamSets ps;
+    EVCParserPoc poc;
+
+    int parsed_extradata;
+} EVCParserContext;
+
 #define NUM_CHROMA_FORMATS      4   // @see ISO_IEC_23094-1 section 6.2 table 2
 
 static const enum AVPixelFormat pix_fmts_8bit[NUM_CHROMA_FORMATS] = {
-- 
2.41.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2023-06-17 22:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-17 15:18 [FFmpeg-devel] [PATCH 1/3] avcodec/evc_frame_merge: use av_fast_realloc() James Almer
2023-06-17 15:18 ` [FFmpeg-devel] [PATCH 2/3] avcodec/evc_frame_merge_bsf: use av_new_packet() James Almer
2023-06-17 15:18 ` [FFmpeg-devel] [PATCH 3/3] fate/lavf-container: add a test to remux raw evc into mp4 James Almer
2023-06-17 22:00 ` [FFmpeg-devel] [PATCH 04/10] avcodec/evc_parse: split off Parameter Set parsing into its own file James Almer
2023-06-20  7:37   ` Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff Engineer/Samsung Electronics
2023-06-20 11:37     ` James Almer
2023-06-17 22:00 ` [FFmpeg-devel] [PATCH 05/10] avcodec/evc_parser: stop exporting delay and gop_size James Almer
2023-06-17 22:00 ` [FFmpeg-devel] [PATCH 06/10] avcodec/evc_parse: split off deriving PoC James Almer
2023-06-17 22:00 ` [FFmpeg-devel] [PATCH 07/10] avcodec/evc_parser: make ff_evc_parse_nal_unit() local to the parser James Almer
2023-06-17 22:00 ` [FFmpeg-devel] [PATCH 08/10] avcodec/evc_parser: remove write only variable James Almer
2023-06-18 12:04   ` Paul B Mahol
2023-06-17 22:00 ` [FFmpeg-devel] [PATCH 09/10] avcodec/evc_frame_merge_bsf: make ff_evc_parse_nal_unit() local to the filter James Almer
2023-06-17 22:00 ` James Almer [this message]
2023-06-18 23:43 ` [FFmpeg-devel] [PATCH 11/17] avformat/evc: don't use an AVIOContext as log context James Almer
2023-06-19 21:11   ` [FFmpeg-devel] [PATCH 11/17 v2] " James Almer
2023-06-20 14:38   ` [FFmpeg-devel] [PATCH 11/17] " James Almer
2023-06-18 23:43 ` [FFmpeg-devel] [PATCH 12/17] avformat/evcdec: deduplicate nalu length and type parsing functions James Almer
2023-06-18 23:43 ` [FFmpeg-devel] [PATCH 13/17] avformat/evcdec: simplify probe function James Almer
2023-06-19 20:29   ` Michael Niedermayer
2023-06-19 20:42     ` James Almer
2023-06-18 23:43 ` [FFmpeg-devel] [PATCH 14/17] avformat/evcdec: simplify au_end_found check James Almer
2023-06-18 23:43 ` [FFmpeg-devel] [PATCH 15/17] avformat/evcdec: don't set AVCodecParameters.framerate James Almer
2023-06-18 23:43 ` [FFmpeg-devel] [PATCH 16/17] avcodec/evc_ps: make ff_evc_parse_{sps, pps} return an error code James Almer
2023-06-18 23:43 ` [FFmpeg-devel] [PATCH 17/17] avcodec/evc_ps: Check log2_sub_gop_length James Almer
2023-06-19 18:28 ` [FFmpeg-devel] [PATCH 1/3] avcodec/evc_frame_merge: use av_fast_realloc() James Almer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230617220015.12669-7-jamrial@gmail.com \
    --to=jamrial@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git