From patchwork Wed Jun 1 09:06:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 36023 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6914:b0:82:6b11:2509 with SMTP id q20csp3309885pzj; Wed, 1 Jun 2022 02:07:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxXFL6jtXJ68PVrMOYgpA6LEhkuaFkIMx0+Sjnijc5QfuCFKOXf5IE93MCuOA7YQ0QaRH4 X-Received: by 2002:aa7:d682:0:b0:42a:cd8e:de41 with SMTP id d2-20020aa7d682000000b0042acd8ede41mr68514870edr.240.1654074452800; Wed, 01 Jun 2022 02:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654074452; cv=none; d=google.com; s=arc-20160816; b=knAK6oEfoYNOLfQAE8XP1qLOzivnLEW9oEHYQuKYIpPYszYDgHgdvrbVLwQIy0nyKR lcxVVPuQk1j6gCph/ez0uhenhZD5Zb7POeQNu7XPZJyn0HvZTdOrhyztlZ3rfIu/7uxr W5qRsoYVR1OhEs1cm2E+Io+lkTrQjTFkcsCurRWWt23yKGgJ6VFPevM5K2vslm1sM66j 1ZRpyR7gXjUNgeOEOk7go43W68ewFLli2TVPL8+ghsFGi/IrAeVsTrE4FV0ISLPLWaSL xlCJOJ7Bz70oCXCgXz6vmKn7mRh6Ok5udmxiXUMAUmx0xOY0fM9WJLIYvvIIN+mO0/Dp lyEg== 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=Xyeeu6xiptHNg3dD2spa2NpAH8owkRq+zXyDUh9wg/aKjfwza2wASTDtOAbRDLVUGe A2RcS7ZLzZAb0B/NJoU9cLgb6gK8LnR+DsvqQ4rklPZkUB8g0Se/ILog2GX1fazERr8U DQ1enESQvB3JHgFpLnq+Xg6OnWEUmzWXJ8VuUslBZANSxF16rEyZz/16+oGVcXEe7rEA bTfB+mJ23SOdr/UCTlC9P5J5uVa4gdi8lh4VXmPI70hMdqUJXsm+BQrupMfO4cbM6adK 1dtvn7f3q5oIMbJD6rgkhWSfTaKjsSXy7F9oUczUbX5h+VG52poleaCSPwoo0VUfHUNt N7Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=mUAAlC4g; 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 sh8-20020a1709076e8800b00707dcb33dc8si672145ejc.402.2022.06.01.02.07.32; Wed, 01 Jun 2022 02:07:32 -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=mUAAlC4g; 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 3509E68B72F; Wed, 1 Jun 2022 12:06:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7E21F68B6F2 for ; Wed, 1 Jun 2022 12:06:12 +0300 (EEST) Received: by mail-pj1-f49.google.com with SMTP id 3-20020a17090a174300b001e426a02ac5so2424084pjm.2; Wed, 01 Jun 2022 02:06:12 -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=mUAAlC4gizYw41mM01hoZrwLcIoPjcZScoAkaXT5TuYYaYl8qGhKS+wPDcAtHH7BRj DE3LEaNmG1xpxQe4dJduPj36CS86iiLIcnMc+X/JM0a8/Fjv/57+37hoWmD/gsNV3api 9P9yalxGoVsAjlv8udbEFJIylLfF54GpNMI01B3adhK7kxaRFtDPaA1j1bscaRrfgHMv zLPjepioYW4j9lcRZsOCRty5ZwHzEKT1j6UyqESzZgflPAIPNWoJoTZTzjjcvLOgEfqz Xj3KQ1Z31K8oYergK6EaDQY7cMud5Ou7lx6/CX/wyfVke2jx+eGYTnLMbySeqqNz1pnr OuwA== 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=dUq6I09hSSkRV6fdrxpzy1EefkD+8kF8+Py/ThwshTWBHTa91OpOa1TPucLqo8bKIM apK6hz+5jiJDAGDjbLX5N00/6Cu3jOw5wSfcUi2ee3Yo22mbjxRvERjyIxadBAitDtCy X2ODCCtiKNnCRsq7T5Syv+hh6/SR3BcdULFpmA2cSmM4PZTv1DveElzR+Ti7lZV2yl2G HoVcug5ierfMM8BMBXwVeg/Q5+nHQWRgucP+9vqrUb/z1iqy2nOPCdho26FU0B7zeIY0 ksUwbcM1ko/deyPhqx6onwzFPkQ3UHbOAgcFLCn4fnJ3+Ijns95SrvaQGRRSwDwILQ6G ZrQA== X-Gm-Message-State: AOAM533AD6Q8S5Q0fnber4yhoZX8/eo/skBugNSHjwMcxv0Rd9J8Gauh qwRq7Cv6e6ufQxToCUyZ5Jdhn6b+Muc= X-Received: by 2002:a17:90a:6390:b0:1e0:a47b:a57a with SMTP id f16-20020a17090a639000b001e0a47ba57amr32806923pjj.115.1654074370903; Wed, 01 Jun 2022 02:06:10 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id l187-20020a6225c4000000b0051b97714703sm906319pfl.187.2022.06.01.02.06.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jun 2022 02:06:10 -0700 (PDT) From: softworkz X-Google-Original-From: softworkz Message-Id: <8082c3ab84a30299f1b8e930a877cf65c3b48b00.1654074366.git.ffmpegagent@gmail.com> In-Reply-To: References: Date: Wed, 01 Jun 2022 09:06:03 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 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: softworkz , "Xiang, Haihao" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: xGaMzWDP3Z+r 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) {