From f291a637d2dc9062ec7bd857e65727ebb44e9da8 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Mon, 16 Jan 2012 09:01:42 -0500 Subject: [PATCH 1/9] initial attempt to declare s436m codec --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 1 + libavcodec/s436m.c | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 libavcodec/s436m.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 29783298010f1..995d15312db93 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -348,6 +348,7 @@ OBJS-$(CONFIG_RV30_DECODER) += rv30.o rv34.o rv30dsp.o \ OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o rv40dsp.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_S302M_DECODER) += s302m.o +OBJS-$(CONFIG_S436M_DECODER) += s436m.o OBJS-$(CONFIG_SGI_DECODER) += sgidec.o OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o OBJS-$(CONFIG_SHORTEN_DECODER) += shorten.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 6226cac3ce261..627135e35a1a2 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -401,6 +401,7 @@ void avcodec_register_all(void) REGISTER_DECODER (BINTEXT, bintext); REGISTER_DECODER (XBIN, xbin); REGISTER_DECODER (IDF, idf); + REGISTER_DECODER (S436M, s436m); /* parsers */ REGISTER_PARSER (AAC, aac); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2b682fa6acf2a..8ef39a95cc31c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -366,6 +366,7 @@ enum CodecID { CODEC_ID_BINTEXT, CODEC_ID_XBIN, CODEC_ID_IDF, + CODEC_ID_S436M, CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it diff --git a/libavcodec/s436m.c b/libavcodec/s436m.c new file mode 100644 index 0000000000000..a0b60a7dd868d --- /dev/null +++ b/libavcodec/s436m.c @@ -0,0 +1,37 @@ +/* + * SMPTE 436m decoder + * Copyright (c) 2011 Dave Rice (dericed@gmail.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * SMPTE 436m Decoder + */ + +AVCodec s436m_decoder = +{ + .name = "s436m", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_S436M, + .priv_data_size = sizeof(S436MContext), + .init = s436m_decode_init, + .close = s436m_decode_close, + .decode = s436m_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets"), +}; From 9317b06f19c4d7478fc8c0967c66f789055403c6 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Fri, 3 Feb 2012 13:08:48 -0500 Subject: [PATCH 2/9] as suggested, consider vbi data as subtitle --- libavcodec/s436m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/s436m.c b/libavcodec/s436m.c index a0b60a7dd868d..4cac8b5f33fec 100644 --- a/libavcodec/s436m.c +++ b/libavcodec/s436m.c @@ -27,7 +27,7 @@ AVCodec s436m_decoder = { .name = "s436m", - .type = AVMEDIA_TYPE_VIDEO, + .type = AVMEDIA_TYPE_SUBTITLE, .id = CODEC_ID_S436M, .priv_data_size = sizeof(S436MContext), .init = s436m_decode_init, From 1e75b3b26c2463f0f4742f379981d38ebff7c20d Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Fri, 3 Feb 2012 17:03:34 -0500 Subject: [PATCH 3/9] remove attempt to make a s346m decoder --- libavcodec/Makefile | 1 - libavcodec/allcodecs.c | 2 +- libavcodec/s436m.c | 37 ------------------------------------- 3 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 libavcodec/s436m.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 995d15312db93..29783298010f1 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -348,7 +348,6 @@ OBJS-$(CONFIG_RV30_DECODER) += rv30.o rv34.o rv30dsp.o \ OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o rv40dsp.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_S302M_DECODER) += s302m.o -OBJS-$(CONFIG_S436M_DECODER) += s436m.o OBJS-$(CONFIG_SGI_DECODER) += sgidec.o OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o OBJS-$(CONFIG_SHORTEN_DECODER) += shorten.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 627135e35a1a2..c77a79dd91f6d 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -373,6 +373,7 @@ void avcodec_register_all(void) REGISTER_DECODER (PGSSUB, pgssub); REGISTER_ENCDEC (SRT, srt); REGISTER_ENCDEC (XSUB, xsub); + REGISTER_DECODER (S436M, s436m); /* external libraries */ REGISTER_ENCODER (LIBAACPLUS, libaacplus); @@ -401,7 +402,6 @@ void avcodec_register_all(void) REGISTER_DECODER (BINTEXT, bintext); REGISTER_DECODER (XBIN, xbin); REGISTER_DECODER (IDF, idf); - REGISTER_DECODER (S436M, s436m); /* parsers */ REGISTER_PARSER (AAC, aac); diff --git a/libavcodec/s436m.c b/libavcodec/s436m.c deleted file mode 100644 index 4cac8b5f33fec..0000000000000 --- a/libavcodec/s436m.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SMPTE 436m decoder - * Copyright (c) 2011 Dave Rice (dericed@gmail.com) - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * SMPTE 436m Decoder - */ - -AVCodec s436m_decoder = -{ - .name = "s436m", - .type = AVMEDIA_TYPE_SUBTITLE, - .id = CODEC_ID_S436M, - .priv_data_size = sizeof(S436MContext), - .init = s436m_decode_init, - .close = s436m_decode_close, - .decode = s436m_decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets"), -}; From 7eabe9187960e4f8f7488e1f7d53199474305604 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sun, 5 Feb 2012 20:23:07 -0500 Subject: [PATCH 4/9] add s364m UL to mxfdec.c --- libavformat/mxfdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 92d93f3b37c62..11e0ec162aef3 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -753,6 +753,7 @@ static const MXFCodecUL mxf_essence_container_uls[] = { { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14, CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14, CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, CODEC_ID_PCM_S16LE }, /* D-10 Mapping 50Mbps PAL Extended Template */ + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x09,0x0D,0x01,0x03,0x01,0x02,0x0E,0x00,0x00 }, 14, CODEC_ID_S436M }, /* SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets */ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, }; From 58dcfb137350babccb0cc29749c608722cf82dc5 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sun, 5 Feb 2012 20:27:37 -0500 Subject: [PATCH 5/9] allcodecs.c: move s364m from subtitle section to a new data section I can't seem to find any precedent for data codecs, so I'm uncertain if this change is correct. --- libavcodec/allcodecs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index c77a79dd91f6d..1a76a11c9a72e 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -373,7 +373,6 @@ void avcodec_register_all(void) REGISTER_DECODER (PGSSUB, pgssub); REGISTER_ENCDEC (SRT, srt); REGISTER_ENCDEC (XSUB, xsub); - REGISTER_DECODER (S436M, s436m); /* external libraries */ REGISTER_ENCODER (LIBAACPLUS, libaacplus); @@ -403,6 +402,9 @@ void avcodec_register_all(void) REGISTER_DECODER (XBIN, xbin); REGISTER_DECODER (IDF, idf); + /* data */ + REGISTER_DECODER (S436M, s436m); + /* parsers */ REGISTER_PARSER (AAC, aac); REGISTER_PARSER (AAC_LATM, aac_latm); From c859fb231577e3bd1359e1474a9c2992b61d7d94 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sun, 5 Feb 2012 20:32:18 -0500 Subject: [PATCH 6/9] add s364m UL to mxf.c --- libavformat/mxf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index b39a9b64cc055..9ac5b5ec1d812 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -52,6 +52,7 @@ const MXFCodecUL ff_mxf_codec_uls[] = { { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 }, 15, CODEC_ID_AC3 }, { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 }, 15, CODEC_ID_MP2 }, /* MP2 or MP3 */ //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, 15, CODEC_ID_DOLBY_E }, /* Dolby-E */ + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x09,0x0D,0x01,0x03,0x01,0x02,0x0E,0x00,0x00 }, 0, CODEC_ID_S436M }, /* SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets */ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, }; From 5cb468f893586ec0e4a54e5235e6086c3860c0fe Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Sun, 5 Feb 2012 21:15:54 -0500 Subject: [PATCH 7/9] remove codec reference from allcodecs.c since there is no decoder --- libavcodec/allcodecs.c | 3 --- libavformat/mxfdec.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 1a76a11c9a72e..6226cac3ce261 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -402,9 +402,6 @@ void avcodec_register_all(void) REGISTER_DECODER (XBIN, xbin); REGISTER_DECODER (IDF, idf); - /* data */ - REGISTER_DECODER (S436M, s436m); - /* parsers */ REGISTER_PARSER (AAC, aac); REGISTER_PARSER (AAC_LATM, aac_latm); diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 11e0ec162aef3..44b797e8fb55d 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -753,7 +753,7 @@ static const MXFCodecUL mxf_essence_container_uls[] = { { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14, CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14, CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, CODEC_ID_PCM_S16LE }, /* D-10 Mapping 50Mbps PAL Extended Template */ - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x09,0x0D,0x01,0x03,0x01,0x02,0x0E,0x00,0x00 }, 14, CODEC_ID_S436M }, /* SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets */ + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x09,0x0D,0x01,0x03,0x01,0x02,0x0E,0x00,0x00 }, 0, CODEC_ID_S436M }, /* SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets */ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, }; From a6909368e616000f1ae1f1da878c2493946a68e5 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Mon, 6 Feb 2012 21:08:16 -0500 Subject: [PATCH 8/9] fix mistakes in UL match length --- libavformat/mxf.c | 2 +- libavformat/mxfdec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 9ac5b5ec1d812..266bca9267b55 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -52,7 +52,7 @@ const MXFCodecUL ff_mxf_codec_uls[] = { { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 }, 15, CODEC_ID_AC3 }, { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 }, 15, CODEC_ID_MP2 }, /* MP2 or MP3 */ //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, 15, CODEC_ID_DOLBY_E }, /* Dolby-E */ - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x09,0x0D,0x01,0x03,0x01,0x02,0x0E,0x00,0x00 }, 0, CODEC_ID_S436M }, /* SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets */ + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x09,0x0D,0x01,0x03,0x01,0x02,0x0E,0x00,0x00 }, 14, CODEC_ID_S436M }, /* SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets */ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, }; diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 44b797e8fb55d..11e0ec162aef3 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -753,7 +753,7 @@ static const MXFCodecUL mxf_essence_container_uls[] = { { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14, CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14, CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, CODEC_ID_PCM_S16LE }, /* D-10 Mapping 50Mbps PAL Extended Template */ - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x09,0x0D,0x01,0x03,0x01,0x02,0x0E,0x00,0x00 }, 0, CODEC_ID_S436M }, /* SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets */ + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x09,0x0D,0x01,0x03,0x01,0x02,0x0E,0x00,0x00 }, 14, CODEC_ID_S436M }, /* SMPTE 436M MXF Mappings for VBI Lines and Ancillary Data Packets */ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, }; From 411543e2e3e7b56ffd5ea8f3643a3464c50c7fd5 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Wed, 8 Feb 2012 00:08:40 -0500 Subject: [PATCH 9/9] trial to get mxfdec.c to recognize s364m --- libavformat/mxfdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 11e0ec162aef3..2ea62c3199d10 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -929,6 +929,10 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) } else if (st->codec->codec_id == CODEC_ID_MP2) { st->need_parsing = AVSTREAM_PARSE_FULL; } + } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) { + container_ul = mxf_get_codec_ul(mxf_essence_container_uls, essence_container_ul); + if (st->codec->codec_id == CODEC_ID_NONE) + st->codec->codec_id = container_ul->id; } if (st->codec->codec_type != AVMEDIA_TYPE_DATA && (*essence_container_ul)[15] > 0x01) { av_log(mxf->fc, AV_LOG_WARNING, "only frame wrapped mappings are correctly supported\n");