diff mbox series

[FFmpeg-devel,2/2] avformat/movenc: fix remuxing eia-608 into mov from other containers

Message ID 20200614162211.30885-2-onemda@gmail.com
State Accepted
Commit 76ad8a568f98483c225d59a9f985dc6d054b6b19
Headers show
Series [FFmpeg-devel,1/2] avformat/mov: fix demuxing of eia-608
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Paul B Mahol June 14, 2020, 4:22 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/movenc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Carl Eugen Hoyos June 14, 2020, 4:31 p.m. UTC | #1
Am So., 14. Juni 2020 um 18:22 Uhr schrieb Paul B Mahol <onemda@gmail.com>:
>
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/movenc.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 5d8dc4fd5d..520aaafb74 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -5582,6 +5582,22 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
>              goto end;
>          avio_write(pb, pkt->data, size);
>  #endif
> +    } else if (par->codec_id == AV_CODEC_ID_EIA_608) {
> +        size = 8;
> +
> +        for (int i = 0; i < pkt->size; i += 3) {
> +            if (pkt->data[i] == 0xFC) {
> +                size += 2;
> +            }
> +        }
> +        avio_wb32(pb, size);
> +        ffio_wfourcc(pb, "cdat");
> +        for (int i = 0; i < pkt->size; i += 3) {
> +            if (pkt->data[i] == 0xFC) {
> +                avio_w8(pb, pkt->data[i + 1]);
> +                avio_w8(pb, pkt->data[i + 2]);
> +            }
> +        }

This answers my question from the other thread, thank you.

Carl Eugen
diff mbox series

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5d8dc4fd5d..520aaafb74 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5582,6 +5582,22 @@  int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
             goto end;
         avio_write(pb, pkt->data, size);
 #endif
+    } else if (par->codec_id == AV_CODEC_ID_EIA_608) {
+        size = 8;
+
+        for (int i = 0; i < pkt->size; i += 3) {
+            if (pkt->data[i] == 0xFC) {
+                size += 2;
+            }
+        }
+        avio_wb32(pb, size);
+        ffio_wfourcc(pb, "cdat");
+        for (int i = 0; i < pkt->size; i += 3) {
+            if (pkt->data[i] == 0xFC) {
+                avio_w8(pb, pkt->data[i + 1]);
+                avio_w8(pb, pkt->data[i + 2]);
+            }
+        }
     } else {
         if (trk->cenc.aes_ctr) {
             if (par->codec_id == AV_CODEC_ID_H264 && par->extradata_size > 4) {