[PATCH 1/9] lavc/codec_desc: add separation comment.
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/codec_desc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index e742b5d..6efc6ec 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2642,6 +2642,8 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"), .props = AV_CODEC_PROP_TEXT_SUB, }, + + /* other kind of codecs and pseudo-codecs */ { .id = AV_CODEC_ID_BINTEXT, .type = AVMEDIA_TYPE_VIDEO, -- 1.7.10.4
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/codec_desc.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 6efc6ec..af4be17 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2684,6 +2684,122 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("timed ID3 metadata"), }, + /* deprecated codec ids */ + { + .id = AV_CODEC_ID_BRENDER_PIX_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "brender_pix_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("BRender PIX image (deprecated id)"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + }, + { + .id = AV_CODEC_ID_ESCAPE130_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "escape130_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("Escape 130 (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_EXR_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "exr_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("OpenEXR image (deprecated id)"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | + AV_CODEC_PROP_LOSSLESS, + }, + { + .id = AV_CODEC_ID_G2M_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "g2m_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("Go2Meeting (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_HEVC_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "hevc_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("H.265 / HEVC (High Efficiency Video Coding) (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_PAF_VIDEO_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "paf_video_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Video (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_SANM_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "sanm_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/SMUSH video (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_VP7_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "vp7_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("On2 VP7 (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_WEBP_DEPRECATED, + .type = AVMEDIA_TYPE_VIDEO, + .name = "webp_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("WebP (deprecated id)"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | + AV_CODEC_PROP_LOSSLESS, + }, + + { + .id = AV_CODEC_ID_VIMA, + .type = AVMEDIA_TYPE_AUDIO, + .name = "vima", + .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_ADPCM_VIMA_DEPRECATED, + .type = AVMEDIA_TYPE_AUDIO, + .name = "adpcm_vima_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_OPUS_DEPRECATED, + .type = AVMEDIA_TYPE_AUDIO, + .name = "opus_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("Opus (Opus Interactive Audio Codec) (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_PAF_AUDIO_DEPRECATED, + .type = AVMEDIA_TYPE_AUDIO, + .name = "paf_audio_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Audio (deprecated id)"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED, + .type = AVMEDIA_TYPE_AUDIO, + .name = "pcm_s24le_planar_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("PCM signed 24-bit little-endian planar (deprecated id)"), + .props = AV_CODEC_PROP_LOSSLESS, + }, + { + .id = AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED, + .type = AVMEDIA_TYPE_AUDIO, + .name = "pcm_s32le_planar_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("PCM signed 32-bit little-endian planar (deprecated id)"), + .props = AV_CODEC_PROP_LOSSLESS, + }, + { + .id = AV_CODEC_ID_TAK_DEPRECATED, + .type = AVMEDIA_TYPE_AUDIO, + .name = "tak_deprecated", + .long_name = NULL_IF_CONFIG_SMALL("TAK (Tom's lossless Audio Kompressor) (deprecated id)"), + .props = AV_CODEC_PROP_LOSSLESS, + }, }; const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id) -- 1.7.10.4
On Thu, Apr 17, 2014 at 10:17:40AM +0200, Nicolas George wrote:
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/codec_desc.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)
LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/codec_desc.c | 12 ++++++++++++ tools/missing_codec_desc | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index af4be17..2513d0b 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2645,6 +2645,12 @@ static const AVCodecDescriptor codec_descriptors[] = { /* other kind of codecs and pseudo-codecs */ { + .id = AV_CODEC_ID_TTF, + .type = AVMEDIA_TYPE_DATA, + .name = "ttf", + .long_name = NULL_IF_CONFIG_SMALL("TrueType font"), + }, + { .id = AV_CODEC_ID_BINTEXT, .type = AVMEDIA_TYPE_VIDEO, .name = "bintext", @@ -2666,6 +2672,12 @@ static const AVCodecDescriptor codec_descriptors[] = { .props = AV_CODEC_PROP_INTRA_ONLY, }, { + .id = AV_CODEC_ID_OTF, + .type = AVMEDIA_TYPE_DATA, + .name = "otf", + .long_name = NULL_IF_CONFIG_SMALL("OpenType font"), + }, + { .id = AV_CODEC_ID_SMPTE_KLV, .type = AVMEDIA_TYPE_DATA, .name = "klv", diff --git a/tools/missing_codec_desc b/tools/missing_codec_desc index 093d02e..e1d3d60 100755 --- a/tools/missing_codec_desc +++ b/tools/missing_codec_desc @@ -14,7 +14,6 @@ known_AV_CODEC_ID_NONE=1 known_AV_CODEC_ID_FIRST_AUDIO=1 known_AV_CODEC_ID_FIRST_SUBTITLE=1 known_AV_CODEC_ID_FIRST_UNKNOWN=1 -known_AV_CODEC_ID_TTF=1 known_AV_CODEC_ID_PROBE=1 known_AV_CODEC_ID_MPEG2TS=1 known_AV_CODEC_ID_MPEG4SYSTEMS=1 -- 1.7.10.4
On Thu, Apr 17, 2014 at 10:17:41AM +0200, Nicolas George wrote:
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/codec_desc.c | 12 ++++++++++++ tools/missing_codec_desc | 1 - 2 files changed, 12 insertions(+), 1 deletion(-)
LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/avcodec.h | 1 + libavcodec/codec_desc.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a7bf52a..ab9d312 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -529,6 +529,7 @@ enum AVCodecID { AV_CODEC_ID_SMPTE_KLV = MKBETAG('K','L','V','A'), AV_CODEC_ID_DVD_NAV = MKBETAG('D','N','A','V'), AV_CODEC_ID_TIMED_ID3 = MKBETAG('T','I','D','3'), + AV_CODEC_ID_BIN_DATA = MKBETAG('D','A','T','A'), AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 2513d0b..464d069 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2695,6 +2695,12 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "timed_id3", .long_name = NULL_IF_CONFIG_SMALL("timed ID3 metadata"), }, + { + .id = AV_CODEC_ID_BIN_DATA, + .type = AVMEDIA_TYPE_DATA, + .name = "bin_data", + .long_name = NULL_IF_CONFIG_SMALL("binary data"), + }, /* deprecated codec ids */ { -- 1.7.10.4
On Thu, Apr 17, 2014 at 10:17:42AM +0200, Nicolas George wrote:
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/avcodec.h | 1 + libavcodec/codec_desc.c | 6 ++++++ 2 files changed, 7 insertions(+)
LGTM when the patch that needs it is applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Freedom in capitalist society always remains about the same as it was in ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/avcodec.h | 7 +++++++ libavcodec/codec_desc.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ab9d312..60565b9 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -567,6 +567,13 @@ typedef struct AVCodecDescriptor { * Codec properties, a combination of AV_CODEC_PROP_* flags. */ int props; + + /** + * MIME type(s) associated with the codec. + * May be NULL; if not, a NULL-terminated array of MIME types. + * The first item is always non-NULL and is the prefered MIME type. + */ + const char *const *mime_types; } AVCodecDescriptor; /** diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 464d069..9edf1e4 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -26,6 +26,8 @@ #include "avcodec.h" #include "version.h" +#define MT(...) (const char *const[]){ __VA_ARGS__, NULL } + static const AVCodecDescriptor codec_descriptors[] = { /* video codecs */ { @@ -85,6 +87,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "mjpeg", .long_name = NULL_IF_CONFIG_SMALL("Motion JPEG"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + .mime_types= MT("image/jpeg"), }, { .id = AV_CODEC_ID_MJPEGB, @@ -526,6 +529,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "bmp", .long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/x-ms-bmp"), }, { .id = AV_CODEC_ID_CSCD, @@ -597,6 +601,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/jp2"), }, { .id = AV_CODEC_ID_VMNC, @@ -1277,6 +1282,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "gif", .long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), .props = AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/gif"), }, { .id = AV_CODEC_ID_JPEGLS, @@ -1299,6 +1305,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "pam", .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/x-portable-pixmap"), }, { .id = AV_CODEC_ID_PBM, @@ -1313,6 +1320,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "pcx", .long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/x-pcx"), }, { .id = AV_CODEC_ID_PGM, @@ -1334,6 +1342,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "png", .long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"), .props = AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/png"), }, { .id = AV_CODEC_ID_PPM, @@ -1376,6 +1385,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "targa", .long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/x-targa", "image/x-tga"), }, { .id = AV_CODEC_ID_TIFF, @@ -1383,6 +1393,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "tiff", .long_name = NULL_IF_CONFIG_SMALL("TIFF image"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/tiff"), }, { .id = AV_CODEC_ID_TXD, @@ -1405,6 +1416,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("WebP"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/webp"), }, { .id = AV_CODEC_ID_WMV3IMAGE, @@ -1426,6 +1438,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "xwd", .long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/x-xwindowdump"), }, /* various PCM "codecs" */ @@ -2649,6 +2662,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_DATA, .name = "ttf", .long_name = NULL_IF_CONFIG_SMALL("TrueType font"), + .mime_types= MT("application/x-truetype-font", "application/x-font"), }, { .id = AV_CODEC_ID_BINTEXT, @@ -2676,6 +2690,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_DATA, .name = "otf", .long_name = NULL_IF_CONFIG_SMALL("OpenType font"), + .mime_types= MT("application/vnd.ms-opentype"), }, { .id = AV_CODEC_ID_SMPTE_KLV, @@ -2700,6 +2715,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_DATA, .name = "bin_data", .long_name = NULL_IF_CONFIG_SMALL("binary data"), + .mime_types= MT("application/octet-stream"), }, /* deprecated codec ids */ -- 1.7.10.4
On Thu, Apr 17, 2014 at 10:17:43AM +0200, Nicolas George wrote:
Signed-off-by: Nicolas George <george@nsup.org> --- libavcodec/avcodec.h | 7 +++++++ libavcodec/codec_desc.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+)
should be ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
The minor bump also covers AV_CODEC_ID_BIN_DATA. TODO fill in the commit hashes. Signed-off-by: Nicolas George <george@nsup.org> --- doc/APIchanges | 3 +++ libavcodec/version.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4cf922b..be43c9c 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2012-10-22 API changes, most recent first: +2014-04-XX - xxxxxxx - lavc xx.xx.1xx - avcodec.h + Add AVCodecDescriptor.mime_types field. + 2014-04-XX - xxxxxxx - lavf xx.xx.1xx - avformat.h Add av_format_inject_global_side_data() diff --git a/libavcodec/version.h b/libavcodec/version.h index 3fbf8ab..b786f0d 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,8 +29,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 55 -#define LIBAVCODEC_VERSION_MINOR 58 -#define LIBAVCODEC_VERSION_MICRO 103 +#define LIBAVCODEC_VERSION_MINOR 59 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 1.7.10.4
On Thu, Apr 17, 2014 at 10:17:44AM +0200, Nicolas George wrote:
The minor bump also covers AV_CODEC_ID_BIN_DATA.
TODO fill in the commit hashes.
Signed-off-by: Nicolas George <george@nsup.org>
LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment.
Avoid long scan and "Could not find codec parameters for stream" error when an attachment has this type. Signed-off-by: Nicolas George <george@nsup.org> --- libavformat/matroska.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 77a88a8..e8e9996 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -113,6 +113,7 @@ const CodecMime ff_mkv_mime_tags[] = { {"application/x-truetype-font", AV_CODEC_ID_TTF}, {"application/x-font" , AV_CODEC_ID_TTF}, {"application/vnd.ms-opentype", AV_CODEC_ID_OTF}, + {"binary" , AV_CODEC_ID_BIN_DATA}, {"" , AV_CODEC_ID_NONE} }; -- 1.7.10.4
On Thu, Apr 17, 2014 at 10:17:45AM +0200, Nicolas George wrote:
Avoid long scan and "Could not find codec parameters for stream" error when an attachment has this type.
probably ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable
Signed-off-by: Nicolas George <george@nsup.org> --- ffprobe.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ffprobe.c b/ffprobe.c index 9e39ff7..d3deb18 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1975,6 +1975,7 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id const char *s; AVRational sar, dar; AVBPrint pbuf; + const AVCodecDescriptor *cd; int ret = 0; av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); @@ -1992,6 +1993,12 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id if (dec->long_name) print_str ("codec_long_name", dec->long_name); else print_str_opt("codec_long_name", "unknown"); } + } else if ((cd = avcodec_descriptor_get(stream->codec->codec_id))) { + print_str_opt("codec_name", cd->name); + if (!do_bitexact) { + print_str_opt("codec_long_name", + cd->long_name ? cd->long_name : "unknown"); + } } else { print_str_opt("codec_name", "unknown"); if (!do_bitexact) { -- 1.7.10.4
On Thu, Apr 17, 2014 at 10:17:46AM +0200, Nicolas George wrote:
Signed-off-by: Nicolas George <george@nsup.org> --- ffprobe.c | 7 +++++++ 1 file changed, 7 insertions(+)
probably ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
On date Thursday 2014-04-17 10:17:46 +0200, Nicolas George encoded:
Signed-off-by: Nicolas George <george@nsup.org> --- ffprobe.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/ffprobe.c b/ffprobe.c index 9e39ff7..d3deb18 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1975,6 +1975,7 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id const char *s; AVRational sar, dar; AVBPrint pbuf; + const AVCodecDescriptor *cd; int ret = 0;
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); @@ -1992,6 +1993,12 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id if (dec->long_name) print_str ("codec_long_name", dec->long_name); else print_str_opt("codec_long_name", "unknown"); } + } else if ((cd = avcodec_descriptor_get(stream->codec->codec_id))) { + print_str_opt("codec_name", cd->name); + if (!do_bitexact) { + print_str_opt("codec_long_name", + cd->long_name ? cd->long_name : "unknown"); + } } else { print_str_opt("codec_name", "unknown"); if (!do_bitexact) {
LGTM -- FFmpeg = Fabulous & Free Merciless Pitiless Eretic Gorilla
TODO changelog version bump Signed-off-by: Nicolas George <george@nsup.org> --- doc/demuxers.texi | 35 ++++++++++++ libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/attachmentdec.c | 133 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 libavformat/attachmentdec.c diff --git a/doc/demuxers.texi b/doc/demuxers.texi index f0a14e0..a246bf8 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -40,6 +40,41 @@ This demuxer is used to demux ASF files and MMS network streams. Do not try to resynchronize by looking for a certain optional start code. @end table +@section attachment + +Attachment pseudo demuxer: this demuxer can read any file as a single +attachment. + +This demuxer accepts the following option: + +@table @option + +@item filename +The declared file name of the attachment (@code{filename} metadata entry). +If not set, the base name of the actual input file name is used. + +@item mime_type +@item mimetype +The declared MIME type of the attachment (@code{mimetype} metadata entry). +If not set, defaults to the MIME type associated to the codec, or +@code{application/octet-stream}. + +@item codec +@item file_codec +The detected codec of the attachment. +If not set, defaults to the codec associated to the MIME type, or binary +data. + +@end table + +Example: attach a font file to a Matroska file: +@example +ffmpeg -i input_raw.ts -i subtitles.ass \ + -f attachment -file_codec ttf -i /path/to/DejaVuSans.ttf \ + -map 0:0 -c:v ... -map 0:1 -c:a ... -map 1 -c:s copy -map 2 \ + output.mkv +@end example + @anchor{concat} @section concat diff --git a/libavformat/Makefile b/libavformat/Makefile index 3df5c88..3c69219 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -81,6 +81,7 @@ OBJS-$(CONFIG_ASS_DEMUXER) += assdec.o subtitles.o OBJS-$(CONFIG_ASS_MUXER) += assenc.o OBJS-$(CONFIG_AST_DEMUXER) += ast.o astdec.o OBJS-$(CONFIG_AST_MUXER) += ast.o astenc.o +OBJS-$(CONFIG_ATTACHMENT_DEMUXER) += attachmentdec.o OBJS-$(CONFIG_AU_DEMUXER) += au.o pcm.o OBJS-$(CONFIG_AU_MUXER) += au.o rawenc.o OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index b5cbbef..72f2ef2 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -79,6 +79,7 @@ void av_register_all(void) REGISTER_MUXDEMUX(ASS, ass); REGISTER_MUXDEMUX(AST, ast); REGISTER_MUXER (ASF_STREAM, asf_stream); + REGISTER_DEMUXER (ATTACHMENT, attachment); REGISTER_MUXDEMUX(AU, au); REGISTER_MUXDEMUX(AVI, avi); REGISTER_DEMUXER (AVISYNTH, avisynth); diff --git a/libavformat/attachmentdec.c b/libavformat/attachmentdec.c new file mode 100644 index 0000000..fab4634 --- /dev/null +++ b/libavformat/attachmentdec.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2014 Nicolas George + * + * 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 + */ + +#include "libavutil/avstring.h" +#include "libavutil/dict.h" +#include "libavutil/opt.h" +#include "avformat.h" +#include "internal.h" + +typedef struct AttachmentContext { + const AVClass *class; + char *filename; + char *mime_type; + char *codec_name; +} AttachmentContext; + +static const AVCodecDescriptor *find_codec_by_mime_type(const char *t) +{ + const AVCodecDescriptor *cd = NULL; + int i; + + while ((cd = avcodec_descriptor_next(cd))) { + if (!cd->mime_types) + continue; + for (i = 0; cd->mime_types[i]; i++) + if (!strcmp(cd->mime_types[i], t)) + return cd; + } + return NULL; +} + +static int attachment_read_header(AVFormatContext *s) +{ + AttachmentContext *att = s->priv_data; + AVStream *st; + int64_t size; + const AVCodecDescriptor *cd = NULL; + const char *filename = att->filename, *mime_type = att->mime_type; + int ret; + + size = avio_size(s->pb); + if (size <= 0) { + av_log(s, AV_LOG_ERROR, "Unknown file size\n"); + return size < 0 ? size : AVERROR_PATCHWELCOME; + } + if (size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { + av_log(s, AV_LOG_ERROR, "File is too big (max size %d)\n", + INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE); + return AVERROR_INVALIDDATA; + } + if (!(st = avformat_new_stream(s, NULL))) + return AVERROR(ENOMEM); + if ((ret = ff_get_extradata(st->codec, s->pb, size)) < 0) + return ret; + + if (!filename && *s->filename) + filename = av_basename(s->filename); + if (att->codec_name) { + if (!(cd = avcodec_descriptor_get_by_name(att->codec_name))) { + av_log(s, AV_LOG_ERROR, "Unknown codec: %s\n", att->codec_name); + return AVERROR(EINVAL); + } + } + if (mime_type && !cd) + cd = find_codec_by_mime_type(att->mime_type); + if (cd && !mime_type && cd->mime_types) + mime_type = cd->mime_types[0]; + if (!mime_type) + mime_type = "application/octet-stream"; + + st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT; + st->codec->codec_id = cd ? cd->id : AV_CODEC_ID_BIN_DATA; + if (filename && *filename) + if ((ret = av_dict_set(&st->metadata, "filename", filename, 0)) < 0) + return AVERROR(ENOMEM); + if (*mime_type) + if ((ret = av_dict_set(&st->metadata, "mimetype", mime_type, 0)) < 0) + return AVERROR(ENOMEM); + return 0; +} + +static int attachment_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + return AVERROR_EOF; +} + +#define OFFSET(field) offsetof(AttachmentContext, field) +#define D AV_OPT_FLAG_DECODING_PARAM + +static const AVOption attachment_options[] = { + { "filename", "filename", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D }, + { "mime_type", "MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D }, + { "mimetype", "MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D }, + { "codec", "codec name", OFFSET(codec_name), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D }, + { "file_codec", "codec name", OFFSET(codec_name), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D }, + { NULL } +}; + +#undef OFFSET +#undef D + +static const AVClass attachment_class = { + .class_name = "attachment", + .item_name = av_default_item_name, + .option = attachment_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_attachment_demuxer = { + .name = "attachment", + .long_name = NULL_IF_CONFIG_SMALL("single attached file"), + .priv_class = &attachment_class, + .priv_data_size = sizeof(AttachmentContext), + .read_header = attachment_read_header, + .read_packet = attachment_read_packet, +}; -- 1.7.10.4
On Thu, Apr 17, 2014 at 10:17:47AM +0200, Nicolas George wrote:
TODO changelog version bump
Signed-off-by: Nicolas George <george@nsup.org> --- doc/demuxers.texi | 35 ++++++++++++ libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/attachmentdec.c | 133 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 libavformat/attachmentdec.c
LGTM also please add some fate test [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad
On Thu, Apr 17, 2014 at 10:17:39AM +0200, Nicolas George wrote:
Signed-off-by: Nicolas George <george@nsup.org>
ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates
participants (3)
-
Michael Niedermayer -
Nicolas George -
Stefano Sabatini