From 0575772fa04e77fbb3755ad1cb8f040713c1e0d7 Mon Sep 17 00:00:00 2001 From: Dale Curtis Date: Wed, 26 Sep 2012 19:21:03 -0700 Subject: [PATCH 1/6] avformat: Identify anonymous AVIO typedef structs. Anonymous typedef structs prevent forward declaration, this change gives the AVIOContext and AVIOInterruptCB structures a name. These structures are now in line with other common structures such as AVFormatContext and AVCodecContext. Signed-off-by: Dale Curtis Signed-off-by: Diego Biurrun --- libavformat/avio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 55c96bc432..96e8e1ce77 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -48,7 +48,7 @@ * new elements have been added after this struct in AVFormatContext * or AVIOContext. */ -typedef struct { +typedef struct AVIOInterruptCB { int (*callback)(void*); void *opaque; } AVIOInterruptCB; @@ -65,7 +65,7 @@ typedef struct { * when implementing custom I/O. Normally these are set to the * function pointers specified in avio_alloc_context() */ -typedef struct { +typedef struct AVIOContext { /** * A class for private options. * From 2a3d82ab467183fd108f451a85ca06ebc2a57e2c Mon Sep 17 00:00:00 2001 From: Andrew D'Addesio Date: Tue, 18 Sep 2012 19:02:14 -0600 Subject: [PATCH 2/6] Add Opus codec id and codec description. Signed-off-by: Diego Biurrun --- libavcodec/avcodec.h | 1 + libavcodec/codec_desc.c | 7 +++++++ libavcodec/version.h | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a89805e558..a7aec4e949 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -405,6 +405,7 @@ enum AVCodecID { AV_CODEC_ID_RALF, AV_CODEC_ID_IAC, AV_CODEC_ID_ILBC, + AV_CODEC_ID_OPUS, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 51fc1714d1..818a35e804 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2105,6 +2105,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_OPUS, + .type = AVMEDIA_TYPE_AUDIO, + .name = "opus", + .long_name = NULL_IF_CONFIG_SMALL("Opus (Opus Interactive Audio Codec)"), + .props = AV_CODEC_PROP_LOSSY, + }, /* subtitle codecs */ { diff --git a/libavcodec/version.h b/libavcodec/version.h index c53286872e..ee70842d0e 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -27,7 +27,7 @@ */ #define LIBAVCODEC_VERSION_MAJOR 54 -#define LIBAVCODEC_VERSION_MINOR 28 +#define LIBAVCODEC_VERSION_MINOR 29 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From bcc1f7caeb3ffce072e7f79412383a2da016f848 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Thu, 27 Sep 2012 02:21:56 -0600 Subject: [PATCH 3/6] Add Opus support to the Ogg muxer. Signed-off-by: Diego Biurrun --- libavformat/oggenc.c | 56 +++++++++++++++++++++++++++++++++++++++---- libavformat/version.h | 2 +- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index c23a1ad836..c1f22d15cc 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -336,6 +336,35 @@ static int ogg_build_speex_headers(AVCodecContext *avctx, return 0; } +#define OPUS_HEADER_SIZE 19 + +static int ogg_build_opus_headers(AVCodecContext *avctx, + OGGStreamContext *oggstream, int bitexact, + AVDictionary **m) +{ + uint8_t *p; + + if (avctx->extradata_size < OPUS_HEADER_SIZE) + return -1; + + /* first packet: Opus header */ + p = av_mallocz(avctx->extradata_size); + if (!p) + return AVERROR(ENOMEM); + oggstream->header[0] = p; + oggstream->header_len[0] = avctx->extradata_size; + bytestream_put_buffer(&p, avctx->extradata, avctx->extradata_size); + + /* second packet: VorbisComment */ + p = ogg_write_vorbiscomment(8, bitexact, &oggstream->header_len[1], m, 0); + if (!p) + return AVERROR(ENOMEM); + oggstream->header[1] = p; + bytestream_put_buffer(&p, "OpusTags", 8); + + return 0; +} + static int ogg_write_header(AVFormatContext *s) { OGGStreamContext *oggstream; @@ -346,13 +375,18 @@ static int ogg_write_header(AVFormatContext *s) unsigned serial_num = i; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) - avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); + if (st->codec->codec_id == AV_CODEC_ID_OPUS) + /* Opus requires a fixed 48kHz clock */ + avpriv_set_pts_info(st, 64, 1, 48000); + else + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den); if (st->codec->codec_id != AV_CODEC_ID_VORBIS && st->codec->codec_id != AV_CODEC_ID_THEORA && st->codec->codec_id != AV_CODEC_ID_SPEEX && - st->codec->codec_id != AV_CODEC_ID_FLAC) { + st->codec->codec_id != AV_CODEC_ID_FLAC && + st->codec->codec_id != AV_CODEC_ID_OPUS) { av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i); return -1; } @@ -394,6 +428,15 @@ static int ogg_write_header(AVFormatContext *s) av_freep(&st->priv_data); return err; } + } else if (st->codec->codec_id == AV_CODEC_ID_OPUS) { + int err = ogg_build_opus_headers(st->codec, oggstream, + st->codec->flags & CODEC_FLAG_BITEXACT, + &s->metadata); + if (err) { + av_log(s, AV_LOG_ERROR, "Error writing Opus headers\n"); + av_freep(&st->priv_data); + return err; + } } else { uint8_t *p; const char *cstr = st->codec->codec_id == AV_CODEC_ID_VORBIS ? "vorbis" : "theora"; @@ -490,7 +533,9 @@ static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt) pframe_count = 0; } granule = (oggstream->last_kf_pts<kfgshift) | pframe_count; - } else + } else if (st->codec->codec_id == AV_CODEC_ID_OPUS) + granule = pkt->pts + pkt->duration + av_rescale_q(st->codec->delay, (AVRational){ 1, st->codec->sample_rate }, st->time_base); + else granule = pkt->pts + pkt->duration; ret = ogg_buffer_data(s, st, pkt->data, pkt->size, granule, 0); @@ -518,7 +563,8 @@ static int ogg_write_trailer(AVFormatContext *s) AVStream *st = s->streams[i]; OGGStreamContext *oggstream = st->priv_data; if (st->codec->codec_id == AV_CODEC_ID_FLAC || - st->codec->codec_id == AV_CODEC_ID_SPEEX) { + st->codec->codec_id == AV_CODEC_ID_SPEEX || + st->codec->codec_id == AV_CODEC_ID_OPUS) { av_free(oggstream->header[0]); } av_freep(&oggstream->header[1]); @@ -531,7 +577,7 @@ AVOutputFormat ff_ogg_muxer = { .name = "ogg", .long_name = NULL_IF_CONFIG_SMALL("Ogg"), .mime_type = "application/ogg", - .extensions = "ogg,ogv,spx", + .extensions = "ogg,ogv,spx,opus", .priv_data_size = sizeof(OGGContext), .audio_codec = AV_CODEC_ID_FLAC, .video_codec = AV_CODEC_ID_THEORA, diff --git a/libavformat/version.h b/libavformat/version.h index f343a38a78..4a4cfe3283 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 54 #define LIBAVFORMAT_VERSION_MINOR 17 -#define LIBAVFORMAT_VERSION_MICRO 2 +#define LIBAVFORMAT_VERSION_MICRO 3 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From 0ae3ba8daaab9b6b2679225f5d08046ffbcd6250 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 24 Sep 2012 16:51:33 +0200 Subject: [PATCH 4/6] avcodec: Drop long-deprecated imgconvert.h header --- libavcodec/imgconvert.c | 1 - libavcodec/imgconvert.h | 44 ----------------------------------------- libavcodec/rawdec.c | 1 - libavcodec/utils.c | 1 - 4 files changed, 47 deletions(-) delete mode 100644 libavcodec/imgconvert.h diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index f6c5e3c476..547bee2405 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -33,7 +33,6 @@ #include "avcodec.h" #include "dsputil.h" #include "internal.h" -#include "imgconvert.h" #include "libavutil/colorspace.h" #include "libavutil/common.h" #include "libavutil/pixdesc.h" diff --git a/libavcodec/imgconvert.h b/libavcodec/imgconvert.h deleted file mode 100644 index c99e587906..0000000000 --- a/libavcodec/imgconvert.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Misc image conversion routines - * most functionality is exported to the public API, see avcodec.h - * - * Copyright (c) 2008 Vitor Sessak - * - * This file is part of Libav. - * - * Libav 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. - * - * Libav 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 Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_IMGCONVERT_H -#define AVCODEC_IMGCONVERT_H - -#include -#include "avcodec.h" - -#if LIBAVCODEC_VERSION_MAJOR < 53 -attribute_deprecated -int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width); - -attribute_deprecated -int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, int height); - -attribute_deprecated -int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane); - -attribute_deprecated -int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt); -#endif - -#endif /* AVCODEC_IMGCONVERT_H */ diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 6f4c0ced3b..ee316ea723 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -25,7 +25,6 @@ */ #include "avcodec.h" -#include "imgconvert.h" #include "raw.h" #include "libavutil/common.h" #include "libavutil/intreadwrite.h" diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0e4048ec6e..c08bad5e02 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -37,7 +37,6 @@ #include "avcodec.h" #include "dsputil.h" #include "libavutil/opt.h" -#include "imgconvert.h" #include "thread.h" #include "audioconvert.h" #include "internal.h" From 83655442fa6dbf7578d108ce479f98a14ebb3e3c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 25 Sep 2012 19:01:10 +0200 Subject: [PATCH 5/6] nutdec: Remove unused and broken debug function stub --- libavformat/nutdec.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 2013bc83b4..2d2c7430af 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -96,18 +96,8 @@ static inline int64_t get_s_trace(AVIOContext *bc, const char *file, return v; } -static inline uint64_t get_vb_trace(AVIOContext *bc, char *file, - char *func, int line) -{ - uint64_t v = get_vb(bc); - - av_log(NULL, AV_LOG_DEBUG, "get_vb %5"PRId64" / %"PRIX64" in %s %s:%d\n", - v, v, file, func, line); - return v; -} #define ffio_read_varlen(bc) get_v_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define get_s(bc) get_s_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_vb(bc) get_vb_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__) #endif static int get_packetheader(NUTContext *nut, AVIOContext *bc, From 4e5b7f31f7aa7a40ef6d255db2cd65ebab7b74db Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 24 Sep 2012 17:07:22 +0200 Subject: [PATCH 6/6] dwt: Drop unused functions spatial_compose{53|97}i() --- libavcodec/dwt.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/libavcodec/dwt.c b/libavcodec/dwt.c index be530396a5..93cf2c6957 100644 --- a/libavcodec/dwt.c +++ b/libavcodec/dwt.c @@ -465,15 +465,6 @@ static void spatial_compose53i_dy(DWTCompose *cs, IDWTELEM *buffer, cs->y += 2; } -static void av_unused spatial_compose53i(IDWTELEM *buffer, IDWTELEM *temp, - int width, int height, int stride) -{ - DWTCompose cs; - spatial_compose53i_init(&cs, buffer, height, stride); - while (cs.y <= height) - spatial_compose53i_dy(&cs, buffer, temp, width, height, stride); -} - void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width) { const int w2 = (width + 1) >> 1; @@ -648,15 +639,6 @@ static void spatial_compose97i_dy(DWTCompose *cs, IDWTELEM *buffer, cs->y += 2; } -static void av_unused spatial_compose97i(IDWTELEM *buffer, IDWTELEM *temp, - int width, int height, int stride) -{ - DWTCompose cs; - spatial_compose97i_init(&cs, buffer, height, stride); - while (cs.y <= height) - spatial_compose97i_dy(&cs, buffer, temp, width, height, stride); -} - void ff_spatial_idwt_buffered_init(DWTCompose *cs, slice_buffer *sb, int width, int height, int stride_line, int type, int decomposition_count)