From: softworkz <ffmpegagent@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: softworkz <softworkz@hotmail.com> Subject: [FFmpeg-devel] [PATCH v9 25/25] avcodec/dvbsubdec: Fix conditions for fallback to default resolution Date: Tue, 25 Oct 2022 09:13:46 +0000 Message-ID: <bb1179897474e20966d5cb7724877ca651fe13d8.1666689226.git.ffmpegagent@gmail.com> (raw) In-Reply-To: <pull.18.v9.ffstaging.FFmpeg.1666689226.ffmpegagent@gmail.com> From: softworkz <softworkz@hotmail.com> The previous code expected a segment of type CLUT definition to exist in order to accept a set of segments to be complete. This was an incorrect assumption as the presence of a CLUT segment is not mandatory. (version 1.6.1 of the spec is probably a bit more clear about this than earlier versions: https://www.etsi.org/deliver/etsi_en/ 300700_300799/300743/01.06.01_20/en_300743v010601a.pdf) The flawed condition prevented proper fallback to using the default resolution for the decoding context. Signed-off-by: softworkz <softworkz@hotmail.com> --- libavcodec/dvbsubdec.c | 51 +++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index c864ba3fb6..4df350574d 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -34,7 +34,7 @@ #define DVBSUB_CLUT_SEGMENT 0x12 #define DVBSUB_OBJECT_SEGMENT 0x13 #define DVBSUB_DISPLAYDEFINITION_SEGMENT 0x14 -#define DVBSUB_DISPLAY_SEGMENT 0x80 +#define DVBSUB_END_DISPLAY_SEGMENT 0x80 #define cm (ff_crop_tab + MAX_NEG_CROP) @@ -1450,8 +1450,12 @@ static int dvbsub_decode(AVCodecContext *avctx, AVSubtitle *sub, int segment_length; int i; int ret = 0; - int got_segment = 0; - int got_dds = 0; + //int got_segment = 0; + int got_page = 0; + int got_region = 0; + int got_object = 0; + int got_end_display = 0; + int got_displaydef = 0; ff_dlog(avctx, "DVB sub packet:\n"); @@ -1496,34 +1500,28 @@ static int dvbsub_decode(AVCodecContext *avctx, AVSubtitle *sub, switch (segment_type) { case DVBSUB_PAGE_SEGMENT: ret = dvbsub_parse_page_segment(avctx, p, segment_length, sub, got_sub_ptr); - got_segment |= 1; + got_page = 1; break; case DVBSUB_REGION_SEGMENT: ret = dvbsub_parse_region_segment(avctx, p, segment_length); - got_segment |= 2; + got_region = 1; break; case DVBSUB_CLUT_SEGMENT: ret = dvbsub_parse_clut_segment(avctx, p, segment_length); if (ret < 0) goto end; - got_segment |= 4; break; case DVBSUB_OBJECT_SEGMENT: ret = dvbsub_parse_object_segment(avctx, p, segment_length); - got_segment |= 8; + got_object = 1; break; case DVBSUB_DISPLAYDEFINITION_SEGMENT: ret = dvbsub_parse_display_definition_segment(avctx, p, segment_length); - got_dds = 1; + got_displaydef = 1; break; - case DVBSUB_DISPLAY_SEGMENT: + case DVBSUB_END_DISPLAY_SEGMENT: ret = dvbsub_display_end_segment(avctx, p, segment_length, sub, got_sub_ptr); - if (got_segment == 15 && !got_dds && !avctx->width && !avctx->height) { - // Default from ETSI EN 300 743 V1.3.1 (7.2.1) - avctx->width = 720; - avctx->height = 576; - } - got_segment |= 16; + got_end_display = 1; break; default: ff_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n", @@ -1536,13 +1534,24 @@ static int dvbsub_decode(AVCodecContext *avctx, AVSubtitle *sub, p += segment_length; } - // Some streams do not send a display segment but if we have all the other - // segments then we need no further data. - if (got_segment == 15) { - av_log(avctx, AV_LOG_DEBUG, "Missing display_end_segment, emulating\n"); - dvbsub_display_end_segment(avctx, p, 0, sub, got_sub_ptr); - } + // Even though not mandated by the spec, we're imposing a minimum requirement + // for a useful packet to have at least one page, region and object segment. + if (got_page && got_region && got_object && got_end_display) { + + if (!got_displaydef && !avctx->width && !avctx->height) { + // Default from ETSI EN 300 743 V1.3.1 (7.2.1) + avctx->width = 720; + avctx->height = 576; + } + + // Some streams do not send an end-of-display segment but if we have all the other + // segments then we need no further data. + if (!got_end_display) { + av_log(avctx, AV_LOG_DEBUG, "Missing display_end_segment, emulating\n"); + dvbsub_display_end_segment(avctx, p, 0, sub, got_sub_ptr); + } + } end: if (ret < 0) { return ret; -- ffmpeg-codebot _______________________________________________ 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".
next prev parent reply other threads:[~2022-10-25 9:17 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <pull.18.v8.ffstaging.FFmpeg.1666591816.ffmpegagent@gmail.com> 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 00/25] Subtitle Filtering 2022 ffmpegagent 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 01/25] avcodec, avutil: Move enum AVSubtitleType to avutil, add new and deprecate old values softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 02/25] avutil/frame: Prepare AVFrame for subtitle handling softworkz 2022-10-25 9:37 ` Hendrik Leppkes 2022-10-25 9:58 ` Soft Works 2022-10-28 20:39 ` Soft Works 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 03/25] avcodec/subtitles: Introduce new frame-based subtitle decoding API softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 04/25] avcodec/libzvbi: set subtitle type softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 05/25] avfilter/subtitles: Update vf_subtitles to use new decoding api softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 06/25] avcodec, avutil: Move ass helper functions to avutil as avpriv_ and extend ass dialog parsing softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 07/25] avcodec/subtitles: Replace deprecated enum values softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 08/25] fftools/play, probe: Adjust for subtitle changes softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 09/25] avfilter/subtitles: Add subtitles.c for subtitle frame allocation softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 10/25] avfilter/avfilter: Handle subtitle frames softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 11/25] avfilter/avfilter: Fix hardcoded input index softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 12/25] avfilter/sbuffer: Add sbuffersrc and sbuffersink filters softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 13/25] avfilter/overlaygraphicsubs: Add overlaygraphicsubs and graphicsub2video filters softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 14/25] avfilter/overlaytextsubs: Add overlaytextsubs and textsubs2video filters softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 15/25] avfilter/textmod: Add textmod, censor and show_speaker filters softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 16/25] avfilter/stripstyles: Add stripstyles filter softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 17/25] avfilter/splitcc: Add splitcc filter for closed caption handling softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 18/25] avfilter/graphicsub2text: Add new graphicsub2text filter (OCR) softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 19/25] avfilter/subscale: Add filter for scaling and/or re-arranging graphical subtitles softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 20/25] avfilter/subfeed: add subtitle feed filter softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 21/25] avfilter/text2graphicsub: Added text2graphicsub subtitle filter softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 22/25] avfilter/snull, strim: Add snull and strim filters softworkz 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 23/25] avcodec/subtitles: Migrate subtitle encoders to frame-based API softworkz 2022-10-27 17:53 ` Michael Niedermayer 2022-10-27 19:05 ` Soft Works 2022-10-25 9:13 ` [FFmpeg-devel] [PATCH v9 24/25] fftools/ffmpeg: Introduce subtitle filtering and new frame-based subtitle encoding softworkz 2022-10-25 9:13 ` softworkz [this message] 2022-11-06 20:52 ` [FFmpeg-devel] [PATCH v9 00/25] Subtitle Filtering 2022 Soft Works
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=bb1179897474e20966d5cb7724877ca651fe13d8.1666689226.git.ffmpegagent@gmail.com \ --to=ffmpegagent@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=softworkz@hotmail.com \ /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