diff mbox series

[FFmpeg-devel,v3,3/3] lavf/mpegts.c: set some properties for ARIB caption

Message ID 20220521172128.716289-4-aimingoff@pc.nifty.jp
State New
Headers show
Series add ARIB caption decoder using libaribcaption | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

TADANO Tokumei May 21, 2022, 5:21 p.m. UTC
Some additional properties are set for ARIB caption.
* need_parsing = 0
  ARIB caption doesn't require any parser.
  This avoids "parser not found" warning message.
* need_context_update = 1
  When any profiles are changed, set this flag to notify.
* codecpar->width / codecpar->height
  Find best video stream and set frame size for ARIB_PROFILE_A
  type of ARIB caption.

Signed-off-by: TADANO Tokumei <aimingoff@pc.nifty.jp>
---
 libavformat/mpegts.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 6e761c07f1..ead833c264 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2145,6 +2145,7 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
             // Vol. 3, Section 2, 4.2.8.1
             int actual_component_tag = sti->stream_identifier - 1;
             int picked_profile = FF_PROFILE_UNKNOWN;
+            AVStream *v_st = NULL;
             int data_component_id = get16(pp, desc_end);
             if (data_component_id < 0)
                 return AVERROR_INVALIDDATA;
@@ -2155,7 +2156,12 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
                 // non-mobile captioning service ("profile A").
                 if (actual_component_tag >= 0x30 &&
                     actual_component_tag <= 0x37) {
+                    int v_index;
                     picked_profile = FF_PROFILE_ARIB_PROFILE_A;
+                    v_index = av_find_best_stream(fc, AVMEDIA_TYPE_VIDEO,
+                                                  -1, 1, NULL, 0);
+                    if (v_index >= 0)
+                        v_st = fc->streams[v_index];
                 }
                 break;
             case 0x0012:
@@ -2174,8 +2180,19 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
 
             st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
             st->codecpar->codec_id   = AV_CODEC_ID_ARIB_CAPTION;
-            st->codecpar->profile    = picked_profile;
+            if (st->codecpar->profile != picked_profile) {
+                st->codecpar->profile = picked_profile;
+                sti->need_context_update = 1;
+            }
+            if (v_st &&
+                (st->codecpar->width != v_st->codecpar->width ||
+                 st->codecpar->height != v_st->codecpar->height)) {
+                st->codecpar->width = v_st->codecpar->width;
+                st->codecpar->height = v_st->codecpar->height;
+                sti->need_context_update = 1;
+            }
             sti->request_probe = 0;
+            sti->need_parsing = 0;
         }
         break;
     case 0xb0: /* DOVI video stream descriptor */