From: rcombs <rcombs@rcombs.me> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] lavc/libaribb24: add default_profile option Date: Wed, 2 Nov 2022 22:19:28 -0500 Message-ID: <20221103031928.3205-1-rcombs@rcombs.me> (raw) 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".
reply other threads:[~2022-11-03 3:19 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20221103031928.3205-1-rcombs@rcombs.me \ --to=rcombs@rcombs.me \ --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