From patchwork Fri Jul 1 20:48:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 36587 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp1261457pzh; Fri, 1 Jul 2022 13:50:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vHWDkhcXKMGjqJGhHWkkkf+pk1aMkwE4Cllk2xINIuy7Fs4ssxz3jevd2G21uqIiIsgrB3 X-Received: by 2002:a17:906:9508:b0:723:ef49:fe4c with SMTP id u8-20020a170906950800b00723ef49fe4cmr16666214ejx.489.1656708610531; Fri, 01 Jul 2022 13:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656708610; cv=none; d=google.com; s=arc-20160816; b=Kb+hzQOf5P3PWTgfa7nJKZy85gQFdRf5yvGN7B/ssbzzmPV8VQL26PRgyS034mtTB+ Fw9UeWjgFCxMZX88/QLQuywaLARGfgy2A/v1jtD1HuVXkI8EBsMFM3MT73pqB/0Sr+H7 yVo5PMuFj4WjdnnMp5cjNnwU75AehbGxHGPRM9FZWfvy6dl1J755wyyyP/mnoWu+c4ZG TlYD3jcrv7gsa77u/X8CpKFAUikV25h2nqabLfqbSPFGyq3RgYRC0eUv1t2KMJ+kqSRe X+U8PaQUAe0iWSE0RI1qG1TkD6yH4LChRVrbB8giBJW3gnCKt4FLtpxyjtHeYW27OmVZ f1MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:mime-version:fcc:date:references :in-reply-to:message-id:from:dkim-signature:delivered-to; bh=kdR1YmSiFbbLGLSkWCpqyM48n5DrPBnChPgyJdhSDhQ=; b=bjq6Jd/HQ6wBABz1UZKt8FLju6EsGkHCVy5p9vpWBsm/EjmwAEJZ2x3Nwkl3cbIcRa Rj0ArV3V7N2Kfa25XDqeriB82NcmHNuieg5FUYahwqlqGOnD0aQkPr3CblVBZX/CenS/ weeg/+x+f9SloRCAQVtR4ZtXA8t0a0w2Cy1BQTMxJxwE2v1c78rKjMU4G0HyCd9Gptd/ SkAhJCrrWpcEska/YK1jk9JakbaNEQp/APf0wOC2yP5GSSAbF2Vo3b0pRBmtVRprDvL8 lFOisevLqWNJe6pZscLurI1ZOz4L0FL8x6uBtHx8I56UkCERH8BOLFdLS+3h5ecTY3uQ k1iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=SnEeQD8L; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q12-20020a056402518c00b00435dde2e2d6si18158820edd.562.2022.07.01.13.50.10; Fri, 01 Jul 2022 13:50:10 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=SnEeQD8L; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 01C1768B81D; Fri, 1 Jul 2022 23:49:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5743F68B786 for ; Fri, 1 Jul 2022 23:49:03 +0300 (EEST) Received: by mail-pf1-f175.google.com with SMTP id a15so3460381pfv.13; Fri, 01 Jul 2022 13:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:in-reply-to:references:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=98LpnvH/HD0Q8JInmZMfJz2v1DbVTAU2FPyI3+P0RhI=; b=SnEeQD8LIzkWf9MQcJANebDniCW6r2xrvo8LdjXEtpOriDb/mnl5DhFhRc2sSVZtNO MeyBBSlDEKWqZMGppWiHfH7rDMdGnPjKcYJNIed7UgoKeLxHF9siZU1QBWPCUfyXF/PN sLAgN6iHExZbWwBrgbdTMVygXxGeDnRQVpwmy2sT61AY7BDUX4VD2fqLiCyXhgcaMlgi Sd8JstLjlrcA3r/4vcfPdCAoaRzjCOB9+XBWyNYQOzmE6WIDH+vqVJjHNtxjgMuHbNXI ZheX/e8SVgFVn7GiL8ZRqp1iF1ujV/4KIEn/g/g3y+rq/l113mnpQ9FW8l3ycRPMIDjS 3Raw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:in-reply-to:references:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=98LpnvH/HD0Q8JInmZMfJz2v1DbVTAU2FPyI3+P0RhI=; b=O2XjN5Um2pBBDvWZSI5CfEu/l6aG06YoYLHUy0iclFtSI84h5P0E5ADvwR3wqCzEMB proQUAzeAsGXOxFOLr1PYf9hnamSi0OX0EcMT4Bh4qtPoZ2rdIahCFlsZGKGFZDmYabk soKj1AVdxG2PMBjeLABABZlGDyNcDr5g6TGC6IDse76pl6rlo9TEVK3O3MHRrFvuI733 MCIvT3n8SD8YEQe+8egV/Jc6e/3I/QDDXioVmmGq+fvJWhUfvIwGA6I60EqhVpkg3/Uy S4HvTfgppZ83jSMXt8Z/U8DMFQX1O82hbZfnRfvb6612/3PrgsCW9D9nJo4ibP4BnSSu 5xew== X-Gm-Message-State: AJIora9QmnNWXsPmk61HHXqxgqdpFhZEKzFlpPEHQP6YFbwjk2XNdwOP qzUx0XNHC8t7OiveMUwATIfGjwjw1YA9sw== X-Received: by 2002:a05:6a00:c:b0:525:55cb:83cd with SMTP id h12-20020a056a00000c00b0052555cb83cdmr22794204pfk.20.1656708541617; Fri, 01 Jul 2022 13:49:01 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id kx10-20020a17090b228a00b001ec9ae91e30sm4629309pjb.12.2022.07.01.13.49.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2022 13:49:00 -0700 (PDT) From: softworkz X-Google-Original-From: softworkz Message-Id: <320a8a535c619defc221b170448272373d367b98.1656708534.git.ffmpegagent@gmail.com> In-Reply-To: References: Date: Fri, 01 Jul 2022 20:48:51 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v5 3/6] avcodec/mpeg12dec: make mpeg_decode_user_data() accessible X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Kieran Kunhya , softworkz , "Xiang, Haihao" , Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ctsJLTCnFrol From: softworkz Signed-off-by: softworkz --- libavcodec/mpeg12.h | 28 ++++++++++++++++++++++++++++ libavcodec/mpeg12dec.c | 40 +++++----------------------------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index e0406b32d9..84a829cdd3 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -23,6 +23,7 @@ #define AVCODEC_MPEG12_H #include "mpegvideo.h" +#include "libavutil/stereo3d.h" /* Start codes. */ #define SEQ_END_CODE 0x000001b7 @@ -34,6 +35,31 @@ #define EXT_START_CODE 0x000001b5 #define USER_START_CODE 0x000001b2 +typedef struct Mpeg1Context { + MpegEncContext mpeg_enc_ctx; + int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ + int repeat_field; /* true if we must repeat the field */ + AVPanScan pan_scan; /* some temporary storage for the panscan */ + AVStereo3D stereo3d; + int has_stereo3d; + AVBufferRef *a53_buf_ref; + uint8_t afd; + int has_afd; + int slice_count; + unsigned aspect_ratio_info; + AVRational save_aspect; + int save_width, save_height, save_progressive_seq; + int rc_buffer_size; + AVRational frame_rate_ext; /* MPEG-2 specific framerate modificator */ + unsigned frame_rate_index; + int sync; /* Did we reach a sync point like a GOP/SEQ/KEYFrame? */ + int closed_gop; + int tmpgexs; + int first_slice; + int extradata_decoded; + int64_t timecode_frame_start; /*< GOP timecode frame start number, in non drop frame format */ +} Mpeg1Context; + void ff_mpeg12_common_init(MpegEncContext *s); void ff_mpeg1_clean_buffers(MpegEncContext *s); @@ -45,4 +71,6 @@ void ff_mpeg12_find_best_frame_rate(AVRational frame_rate, int *code, int *ext_n, int *ext_d, int nonstandard); +void ff_mpeg_decode_user_data(AVCodecContext *avctx, Mpeg1Context *s1, const uint8_t *p, int buf_size); + #endif /* AVCODEC_MPEG12_H */ diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index e9bde48f7a..11d2b58185 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -58,31 +58,6 @@ #define A53_MAX_CC_COUNT 2000 -typedef struct Mpeg1Context { - MpegEncContext mpeg_enc_ctx; - int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ - int repeat_field; /* true if we must repeat the field */ - AVPanScan pan_scan; /* some temporary storage for the panscan */ - AVStereo3D stereo3d; - int has_stereo3d; - AVBufferRef *a53_buf_ref; - uint8_t afd; - int has_afd; - int slice_count; - unsigned aspect_ratio_info; - AVRational save_aspect; - int save_width, save_height, save_progressive_seq; - int rc_buffer_size; - AVRational frame_rate_ext; /* MPEG-2 specific framerate modificator */ - unsigned frame_rate_index; - int sync; /* Did we reach a sync point like a GOP/SEQ/KEYFrame? */ - int closed_gop; - int tmpgexs; - int first_slice; - int extradata_decoded; - int64_t timecode_frame_start; /*< GOP timecode frame start number, in non drop frame format */ -} Mpeg1Context; - #define MB_TYPE_ZERO_MV 0x20000000 static const uint32_t ptype2mb_type[7] = { @@ -2198,11 +2173,9 @@ static int vcr2_init_sequence(AVCodecContext *avctx) return 0; } -static int mpeg_decode_a53_cc(AVCodecContext *avctx, +static int mpeg_decode_a53_cc(AVCodecContext *avctx, Mpeg1Context *s1, const uint8_t *p, int buf_size) { - Mpeg1Context *s1 = avctx->priv_data; - if (buf_size >= 6 && p[0] == 'G' && p[1] == 'A' && p[2] == '9' && p[3] == '4' && p[4] == 3 && (p[5] & 0x40)) { @@ -2333,12 +2306,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, return 0; } -static void mpeg_decode_user_data(AVCodecContext *avctx, - const uint8_t *p, int buf_size) +void ff_mpeg_decode_user_data(AVCodecContext *avctx, Mpeg1Context *s1, const uint8_t *p, int buf_size) { - Mpeg1Context *s = avctx->priv_data; const uint8_t *buf_end = p + buf_size; - Mpeg1Context *s1 = avctx->priv_data; #if 0 int i; @@ -2352,7 +2322,7 @@ static void mpeg_decode_user_data(AVCodecContext *avctx, int i; for(i=0; i<20; i++) if (!memcmp(p+i, "\0TMPGEXS\0", 9)){ - s->tmpgexs= 1; + s1->tmpgexs= 1; } } /* we parse the DTG active format information */ @@ -2398,7 +2368,7 @@ static void mpeg_decode_user_data(AVCodecContext *avctx, break; } } - } else if (mpeg_decode_a53_cc(avctx, p, buf_size)) { + } else if (mpeg_decode_a53_cc(avctx, s1, p, buf_size)) { return; } } @@ -2590,7 +2560,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, } break; case USER_START_CODE: - mpeg_decode_user_data(avctx, buf_ptr, input_size); + ff_mpeg_decode_user_data(avctx, s, buf_ptr, input_size); break; case GOP_START_CODE: if (last_code == 0) {