From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 255A048C9F for ; Wed, 24 Jan 2024 08:18:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0880F68D15B; Wed, 24 Jan 2024 10:17:32 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4FF768C99B for ; Wed, 24 Jan 2024 10:17:21 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=B4PTsfhs; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 366E119BC for ; Wed, 24 Jan 2024 09:17:21 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 2HQKKBRLFFhJ for ; Wed, 24 Jan 2024 09:17:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1706084239; bh=1rHCMpvZgWq46zc1qVriKhgC//d9CH53hp5uMbAdsb0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B4PTsfhsP+AikBMrN8kQ6Po5V3dAfapqFmeO3S3Q7+F9HfZ/hOasEvE+xJB+yoqNS CNkDEyMwY3UYKT+9lmINM1QakijNh+ztZHyAuMNUMwhJ96vRzsJvx8sZZ20dPrNbS3 nK8ZIfPNJeYGsMq9fR/PoTTjyiCaawhf4RYcWDGBptzdGLWjVW4/gd9agqJYFjX2dA aCixAGGpd/spQA0LlKd/q3SZZncwcxPyBUNj3STO2+AILvcVG3sn4fci93NjRxall8 xLjkHBGYihMLt/sk2sbg+ii3oHEn0f0E7pUksn3+tU18XSs2kH88ycK17uCLYFDMro izgu1VH4BB7qw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 45E0BEEB for ; Wed, 24 Jan 2024 09:17:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2E3893A054A for ; Wed, 24 Jan 2024 09:17:19 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Jan 2024 09:16:32 +0100 Message-ID: <20240124081702.4759-2-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240124081702.4759-1-anton@khirnov.net> References: <20240124081702.4759-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/31] fftools/ffmpeg_dec: export subtitle_header in Decoder 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This way the encoder does not need to access the decoder AVCodecContext, which will allow to make it private in future commits. --- fftools/ffmpeg.h | 3 ++- fftools/ffmpeg_dec.c | 3 +++ fftools/ffmpeg_enc.c | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 429c1aba85..4c9424d02f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -281,7 +281,8 @@ typedef struct FilterGraph { } FilterGraph; typedef struct Decoder { - char dummy; + const uint8_t *subtitle_header; + int subtitle_header_size; } Decoder; typedef struct InputStream { diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index fd697c5f1e..cb967d5930 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -969,5 +969,8 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx) if (ret < 0) return ret; + dp->dec.subtitle_header = ist->dec_ctx->subtitle_header; + dp->dec.subtitle_header_size = ist->dec_ctx->subtitle_header_size; + return 0; } diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 2a7fba0c51..bbd86a6fe1 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -171,7 +171,7 @@ int enc_open(void *opaque, const AVFrame *frame) InputStream *ist = ost->ist; Encoder *e = ost->enc; AVCodecContext *enc_ctx = ost->enc_ctx; - AVCodecContext *dec_ctx = NULL; + Decoder *dec; const AVCodec *enc = enc_ctx->codec; OutputFile *of = ost->file; FrameData *fd; @@ -193,9 +193,8 @@ int enc_open(void *opaque, const AVFrame *frame) if (ret < 0) return ret; - if (ist) { - dec_ctx = ist->dec_ctx; - } + if (ist) + dec = ist->decoder; // the timebase is chosen by filtering code if (ost->type == AVMEDIA_TYPE_AUDIO || ost->type == AVMEDIA_TYPE_VIDEO) { @@ -279,14 +278,16 @@ int enc_open(void *opaque, const AVFrame *frame) enc_ctx->width = ost->ist->par->width; enc_ctx->height = ost->ist->par->height; } - if (dec_ctx && dec_ctx->subtitle_header) { + + av_assert0(dec); + if (dec->subtitle_header) { /* ASS code assumes this buffer is null terminated so add extra byte. */ - enc_ctx->subtitle_header = av_mallocz(dec_ctx->subtitle_header_size + 1); + enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); if (!enc_ctx->subtitle_header) return AVERROR(ENOMEM); - memcpy(enc_ctx->subtitle_header, dec_ctx->subtitle_header, - dec_ctx->subtitle_header_size); - enc_ctx->subtitle_header_size = dec_ctx->subtitle_header_size; + memcpy(enc_ctx->subtitle_header, dec->subtitle_header, + dec->subtitle_header_size); + enc_ctx->subtitle_header_size = dec->subtitle_header_size; } break; -- 2.42.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".