diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-09-27 02:14:37 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-09-27 02:14:37 +0200 |
commit | 7c1aba4f01a10915d356c7bc0c6bfed25cbb623e (patch) | |
tree | a3452b5224630d3ea4ace5f2d143051c7aab5c8d /libavformat | |
parent | c2a016ad4d9c29285813ba5806189e63e063e0fb (diff) | |
parent | 908f12f342341785bf0458e88a06d97a1af90339 (diff) | |
download | ffmpeg-7c1aba4f01a10915d356c7bc0c6bfed25cbb623e.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (21 commits)
fate: allow testing with libavfilter disabled
x86: XOP/FMA4 CPU detection support
ws_snd: misc cosmetic clean-ups
ws_snd: remove the 2-bit ADPCM table and just subtract 2 instead.
ws_snd: use memcpy() and memset() instead of loops
ws_snd: use samples pointer for loop termination instead of a separate iterator variable.
ws_snd: make sure number of channels is 1
ws_snd: add some checks to prevent buffer overread or overwrite.
ws_snd: decode to AV_SAMPLE_FMT_U8 instead of S16.
flacdec: fix buffer size checking in get_metadata_size()
rtp: Simplify ff_rtp_get_payload_type
rtpenc: Add a payload type private option
rtp: Correct ff_rtp_get_payload_type documentation
avconv: replace all fprintf() by av_log().
avconv: change av_log verbosity from ERROR to FATAL for fatal errors.
cmdutils: replace fprintf() by av_log()
avtools: parse loglevel before all the other options.
oggdec: add support for Xiph's CELT codec
sol: return error if av_get_packet() fails.
cosmetics: reindent and pretty-print
...
Conflicts:
avconv.c
cmdutils.c
libavcodec/avcodec.h
libavcodec/version.h
libavformat/oggparsecelt.c
libavformat/utils.c
libavutil/avutil.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/oggparsecelt.c | 26 | ||||
-rw-r--r-- | libavformat/rtp.c | 24 | ||||
-rw-r--r-- | libavformat/rtp.h | 10 | ||||
-rw-r--r-- | libavformat/rtpenc.c | 4 | ||||
-rw-r--r-- | libavformat/sdp.c | 2 | ||||
-rw-r--r-- | libavformat/sol.c | 2 | ||||
-rw-r--r-- | libavformat/utils.c | 16 |
7 files changed, 46 insertions, 38 deletions
diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c index 2adc06046a..90fae7d777 100644 --- a/libavformat/oggparsecelt.c +++ b/libavformat/oggparsecelt.c @@ -20,9 +20,10 @@ */ #include <string.h> + +#include "libavutil/intreadwrite.h" #include "avformat.h" #include "oggdec.h" -#include "libavutil/intreadwrite.h" struct oggcelt_private { int extra_headers_left; @@ -38,11 +39,10 @@ static int celt_header(AVFormatContext *s, int idx) if (os->psize == 60 && !memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) { - /* Main header */ - uint32_t version, header_size av_unused, sample_rate, nb_channels, frame_size; - uint32_t overlap, bytes_per_packet av_unused, extra_headers; + uint32_t version, sample_rate, nb_channels, frame_size; + uint32_t overlap, extra_headers; uint8_t *extradata; extradata = av_malloc(2 * sizeof(uint32_t) + @@ -54,12 +54,12 @@ static int celt_header(AVFormatContext *s, int idx) return AVERROR(ENOMEM); } version = AV_RL32(p + 28); - header_size = AV_RL32(p + 32); /* unused */ + /* unused header size field skipped */ sample_rate = AV_RL32(p + 36); nb_channels = AV_RL32(p + 40); frame_size = AV_RL32(p + 44); overlap = AV_RL32(p + 48); - bytes_per_packet = AV_RL32(p + 52); /* unused */ + /* unused bytes per packet field skipped */ extra_headers = AV_RL32(p + 56); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_CELT; @@ -67,25 +67,23 @@ static int celt_header(AVFormatContext *s, int idx) st->codec->channels = nb_channels; st->codec->frame_size = frame_size; st->codec->sample_fmt = AV_SAMPLE_FMT_S16; - av_set_pts_info(st, 64, 1, sample_rate); + av_free(st->codec->extradata); + st->codec->extradata = extradata; + st->codec->extradata_size = 2 * sizeof(uint32_t); + if (sample_rate) + av_set_pts_info(st, 64, 1, sample_rate); priv->extra_headers_left = 1 + extra_headers; av_free(os->private); os->private = priv; AV_WL32(extradata + 0, overlap); AV_WL32(extradata + 4, version); - av_free(st->codec->extradata); - st->codec->extradata = extradata; - st->codec->extradata_size = 2 * sizeof(uint32_t); return 1; - - } else if(priv && priv->extra_headers_left) { - + } else if (priv && priv->extra_headers_left) { /* Extra headers (vorbiscomment) */ ff_vorbis_comment(s, &st->metadata, p, os->psize); priv->extra_headers_left--; return 1; - } else { return 0; } diff --git a/libavformat/rtp.c b/libavformat/rtp.c index ab815233ab..6028fe0b82 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <libavutil/opt.h> #include "avformat.h" #include "rtp.h" @@ -89,26 +90,31 @@ int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type) return -1; } -int ff_rtp_get_payload_type(AVCodecContext *codec) +int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec) { - int i, payload_type; + int i; + AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL; + + /* Was the payload type already specified for the RTP muxer? */ + if (ofmt && ofmt->priv_class) { + int payload_type = av_get_int(fmt->priv_data, "payload_type", NULL); + if (payload_type >= 0) + return payload_type; + } - /* compute the payload type */ - for (payload_type = -1, i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i) + /* static payload type */ + for (i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i) if (AVRtpPayloadTypes[i].codec_id == codec->codec_id) { if (codec->codec_id == CODEC_ID_H263) continue; if (codec->codec_id == CODEC_ID_PCM_S16BE) if (codec->channels != AVRtpPayloadTypes[i].audio_channels) continue; - payload_type = AVRtpPayloadTypes[i].pt; + return AVRtpPayloadTypes[i].pt; } /* dynamic payload type */ - if (payload_type < 0) - payload_type = RTP_PT_PRIVATE + (codec->codec_type == AVMEDIA_TYPE_AUDIO); - - return payload_type; + return RTP_PT_PRIVATE + (codec->codec_type == AVMEDIA_TYPE_AUDIO); } const char *ff_rtp_enc_name(int payload_type) diff --git a/libavformat/rtp.h b/libavformat/rtp.h index f550ad73d2..5297e17f6a 100644 --- a/libavformat/rtp.h +++ b/libavformat/rtp.h @@ -21,17 +21,17 @@ #ifndef AVFORMAT_RTP_H #define AVFORMAT_RTP_H +#include "libavformat/avformat.h" #include "libavcodec/avcodec.h" /** - * Return the payload type for a given codec. + * Return the payload type for a given codec used in the given format context. * + * @param fmt The context of the format * @param codec The context of the codec - * @return In case of unknown payload type or dynamic payload type, a - * negative value is returned; otherwise, the payload type (the 'PT' field - * in the RTP header) is returned. + * @return The payload type (the 'PT' field in the RTP header). */ -int ff_rtp_get_payload_type(AVCodecContext *codec); +int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec); /** * Initialize a codec context based on the payload type. diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index 0cc68fc64a..a336c64b37 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -32,6 +32,7 @@ static const AVOption options[] = { FF_RTP_FLAG_OPTS(RTPMuxContext, flags), + { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; @@ -92,7 +93,8 @@ static int rtp_write_header(AVFormatContext *s1) return -1; } - s->payload_type = ff_rtp_get_payload_type(st->codec); + if (s->payload_type < 0) + s->payload_type = ff_rtp_get_payload_type(s1, st->codec); s->base_timestamp = av_get_random_seed(); s->timestamp = s->base_timestamp; s->cur_timestamp = 0; diff --git a/libavformat/sdp.c b/libavformat/sdp.c index fb351bb97b..5f3ed1c4b1 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -532,7 +532,7 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des const char *type; int payload_type; - payload_type = ff_rtp_get_payload_type(c); + payload_type = ff_rtp_get_payload_type(fmt, c); switch (c->codec_type) { case AVMEDIA_TYPE_VIDEO : type = "video" ; break; diff --git a/libavformat/sol.c b/libavformat/sol.c index 895623392c..1389128fa6 100644 --- a/libavformat/sol.c +++ b/libavformat/sol.c @@ -132,6 +132,8 @@ static int sol_read_packet(AVFormatContext *s, if (url_feof(s->pb)) return AVERROR(EIO); ret= av_get_packet(s->pb, pkt, MAX_SIZE); + if (ret < 0) + return ret; pkt->stream_index = 0; /* note: we need to modify the packet size here to handle the last diff --git a/libavformat/utils.c b/libavformat/utils.c index cba397b0ae..7c8095973f 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2122,14 +2122,14 @@ static int has_codec_parameters(AVCodecContext *avctx) switch (avctx->codec_type) { case AVMEDIA_TYPE_AUDIO: val = avctx->sample_rate && avctx->channels && avctx->sample_fmt != AV_SAMPLE_FMT_NONE; - if(!avctx->frame_size && - (avctx->codec_id == CODEC_ID_VORBIS || - avctx->codec_id == CODEC_ID_AAC || - avctx->codec_id == CODEC_ID_MP1 || - avctx->codec_id == CODEC_ID_MP2 || - avctx->codec_id == CODEC_ID_MP3 || - avctx->codec_id == CODEC_ID_SPEEX || - avctx->codec_id == CODEC_ID_CELT)) + if (!avctx->frame_size && + (avctx->codec_id == CODEC_ID_VORBIS || + avctx->codec_id == CODEC_ID_AAC || + avctx->codec_id == CODEC_ID_MP1 || + avctx->codec_id == CODEC_ID_MP2 || + avctx->codec_id == CODEC_ID_MP3 || + avctx->codec_id == CODEC_ID_SPEEX || + avctx->codec_id == CODEC_ID_CELT)) return 0; break; case AVMEDIA_TYPE_VIDEO: |