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 9C5894010C for ; Thu, 3 Nov 2022 03:19:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17B2D68BE00; Thu, 3 Nov 2022 05:19:44 +0200 (EET) Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 17CB768BE25 for ; Thu, 3 Nov 2022 05:19:38 +0200 (EET) Received: by mail-io1-f51.google.com with SMTP id r81so402245iod.2 for ; Wed, 02 Nov 2022 20:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rcombs.me; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Kxul5S9yhp3LFtBgG+Z8NzPs/oDpHE2O2KaCbCyTD1I=; b=epyAE5EPI5eWWRAbi6Ft04h+rFFK2/QhKTuFMxWyZFAc9quxhJgp8ME831YTssJhPl 7RgXWfynO8WjfxC9uAX7rvfwPM65qLmbbdbG/qkl0bA61gQ4E8fw9DfcyKnsa4UKKp5H GytM7nrbm8ZPXceOB2AbIuaHSBxBoNpO1uWX2RvU/PyxZRmjt/M9cm+V6cl2+rAzP5Rz hBjJ3DGzw0rMgHc5174XLd7Z25nzYTFrlnve2rcDvlXnXaAFGNQwdXm5Hfm8iUx2nIaZ OvYRt+eMDilE6yU1RsGsjPX7hvoDEQa1WhjRwbPm/PvpmYQsoz3Mw5yRc/I1+cpv929i 6Z7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Kxul5S9yhp3LFtBgG+Z8NzPs/oDpHE2O2KaCbCyTD1I=; b=tKzE0GRFCpRJosmV0h3dUoMSoHrZ3E61ZoJ3MRXyaCOWZHg4apIODlpQGz+77iIFF8 McG9DdjQJym5BKhjZe31ol7JFdrhL0IlGHVi5xRFNtk9yBCQtCq9Gsn197d1uywM3k1f 0rZ43I+4b4R0OY+NkGzQ20ODY/55OVh20E2rX8jRc/jvN2qSh5eWBk7w9R5f9Z8hAsNX /gYWfuKhG6G/hCXq0yZzXff89C8IhL/GurKDm2O+RRmeopY5zAOjJ9oxG4c9v2eoYW// IVwBqzxEayh6zmYPRjBHVz21esVwrtQDAihFOxL4Ermvs79juPXUgid8nmoncpNYN5pk E8gg== X-Gm-Message-State: ACrzQf1Z2dQzBOcrZo00qTh71Lu4SXRS2Fid6ebwBLTrwKskkD4G1KLI zHAui2Tudm4eSSPrV5vqDjeq5YvLRewk X-Google-Smtp-Source: AMsMyM4hjG4kLDJ5KEhq4uREK7TYKQAUa9Iv5P5gP1FVPb+SACkBxi8De7wck0NHVUVRbDpRO+7xtw== X-Received: by 2002:a05:6602:164b:b0:6cf:bc3f:fcd5 with SMTP id y11-20020a056602164b00b006cfbc3ffcd5mr14179076iow.119.1667445576026; Wed, 02 Nov 2022 20:19:36 -0700 (PDT) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:68b3:5bec:e69c:d6c6]) by smtp.gmail.com with ESMTPSA id g9-20020a025b09000000b00363dfbb145asm5335692jab.30.2022.11.02.20.19.34 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Nov 2022 20:19:35 -0700 (PDT) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Nov 2022 22:19:28 -0500 Message-Id: <20221103031928.3205-1-rcombs@rcombs.me> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/libaribb24: add default_profile option 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 allows decoding of streams that don't have a profile tagged (e.g. ones that were remuxed improperly). --- libavcodec/libaribb24.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/libavcodec/libaribb24.c b/libavcodec/libaribb24.c index f40517e22e..8ccf3c4b5d 100644 --- a/libavcodec/libaribb24.c +++ b/libavcodec/libaribb24.c @@ -40,10 +40,18 @@ typedef struct Libaribb24Context { char *aribb24_base_path; unsigned int aribb24_skip_ruby; + + int default_profile; } Libaribb24Context; -static unsigned int get_profile_font_size(int profile) +static unsigned int get_profile_font_size(AVCodecContext *avctx) { + Libaribb24Context *b24 = avctx->priv_data; + int profile = avctx->profile; + + if (profile == FF_PROFILE_UNKNOWN) + profile = b24->default_profile; + switch (profile) { case FF_PROFILE_ARIB_PROFILE_A: return 36; @@ -61,26 +69,31 @@ static void libaribb24_log(void *p, const char *msg) static int libaribb24_generate_ass_header(AVCodecContext *avctx) { + Libaribb24Context *b24 = avctx->priv_data; unsigned int plane_width = 0; unsigned int plane_height = 0; unsigned int font_size = 0; + int profile = avctx->profile; - switch (avctx->profile) { + if (profile == FF_PROFILE_UNKNOWN) + profile = b24->default_profile; + + switch (profile) { case FF_PROFILE_ARIB_PROFILE_A: plane_width = 960; plane_height = 540; - font_size = get_profile_font_size(avctx->profile); break; case FF_PROFILE_ARIB_PROFILE_C: plane_width = 320; plane_height = 180; - font_size = get_profile_font_size(avctx->profile); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown or unsupported profile set!\n"); return AVERROR(EINVAL); } + font_size = get_profile_font_size(avctx); + avctx->subtitle_header = av_asprintf( "[Script Info]\r\n" "; Script generated by FFmpeg/Lavc%s\r\n" @@ -135,6 +148,7 @@ static int libaribb24_init(AVCodecContext *avctx) Libaribb24Context *b24 = avctx->priv_data; void(* arib_dec_init)(arib_decoder_t* decoder) = NULL; int ret_code = AVERROR_EXTERNAL; + int profile = avctx->profile; if (!(b24->lib_instance = arib_instance_new(avctx))) { av_log(avctx, AV_LOG_ERROR, "Failed to initialize libaribb24!\n"); @@ -158,7 +172,10 @@ static int libaribb24_init(AVCodecContext *avctx) goto init_fail; } - switch (avctx->profile) { + if (profile == FF_PROFILE_UNKNOWN) + profile = b24->default_profile; + + switch (profile) { case FF_PROFILE_ARIB_PROFILE_A: arib_dec_init = arib_initialize_decoder_a_profile; break; @@ -209,7 +226,7 @@ static int libaribb24_handle_regions(AVCodecContext *avctx, AVSubtitle *sub) { Libaribb24Context *b24 = avctx->priv_data; const arib_buf_region_t *region = arib_decoder_get_regions(b24->decoder); - unsigned int profile_font_size = get_profile_font_size(avctx->profile); + unsigned int profile_font_size = get_profile_font_size(avctx); AVBPrint buf = { 0 }; int ret = 0; @@ -371,6 +388,10 @@ static const AVOption options[] = { OFFSET(aribb24_base_path), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD }, { "aribb24-skip-ruby-text", "skip ruby text blocks during decoding", OFFSET(aribb24_skip_ruby), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD }, + { "default_profile", "default profile to use if not specified in the stream parameters", + OFFSET(default_profile), AV_OPT_TYPE_INT, { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, FF_PROFILE_ARIB_PROFILE_C, SD, "profile" }, + {"a", "Profile A", 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_ARIB_PROFILE_A}, INT_MIN, INT_MAX, SD, "profile"}, + {"c", "Profile C", 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_ARIB_PROFILE_C}, INT_MIN, INT_MAX, SD, "profile"}, { NULL } }; -- 2.38.1 _______________________________________________ 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".