summaryrefslogtreecommitdiff
path: root/libavformat/rtpdec_g726.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-01 02:44:19 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-01 02:54:24 +0100
commit9d76cf0b18976487d71e39bbdc1b53755e366535 (patch)
treed71801d63301c89e4c860eb2dee38b47348cd5b7 /libavformat/rtpdec_g726.c
parent0275b75a7e705ef5a6bd6610f1450671f78000b6 (diff)
parentc8f0e88b205208da0e74f9345d4c4eb6d725774b (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: rtpdec: Templatize the code for different g726 bitrate variants rv40: move loop filter to rv34dsp context lavf: make av_set_pts_info private. rtpdec: Add support for G726 audio rtpdec: Add an init function that can do custom codec context initialization avconv: make copy_tb on by default. matroskadec: don't set codec timebase. rmdec: don't set codec timebase. avconv: compute next_pts from input packet duration when possible. lavf: estimate frame duration from r_frame_rate. avconv: update InputStream.pts in the streamcopy case. Conflicts: avconv.c libavdevice/alsa-audio-dec.c libavdevice/bktr.c libavdevice/fbdev.c libavdevice/libdc1394.c libavdevice/oss_audio.c libavdevice/v4l.c libavdevice/v4l2.c libavdevice/vfwcap.c libavdevice/x11grab.c libavformat/au.c libavformat/eacdata.c libavformat/flvdec.c libavformat/mpegts.c libavformat/mxfenc.c libavformat/rtpdec_g726.c libavformat/wtv.c libavformat/xmv.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtpdec_g726.c')
-rw-r--r--libavformat/rtpdec_g726.c92
1 files changed, 23 insertions, 69 deletions
diff --git a/libavformat/rtpdec_g726.c b/libavformat/rtpdec_g726.c
index cde832b21a..35ca9061fd 100644
--- a/libavformat/rtpdec_g726.c
+++ b/libavformat/rtpdec_g726.c
@@ -21,74 +21,28 @@
#include "avformat.h"
#include "rtpdec_formats.h"
-static int g726_16_parse_sdp_line(AVFormatContext *s, int st_index,
- PayloadContext *data, const char *line)
-{
- AVStream *stream = s->streams[st_index];
- AVCodecContext *codec = stream->codec;
-
- codec->bit_rate = 16000;
-
- return 0;
+#define RTP_G726_HANDLER(bitrate) \
+static int g726_ ## bitrate ##_init(AVFormatContext *s, int st_index, PayloadContext *data) \
+{ \
+ AVStream *stream = s->streams[st_index]; \
+ AVCodecContext *codec = stream->codec; \
+\
+ codec->bit_rate = bitrate*1000; \
+ if (codec->sample_rate) \
+ codec->bits_per_coded_sample = \
+ av_clip((codec->bit_rate + codec->sample_rate/2) / codec->sample_rate, 2, 5); \
+\
+ return 0; \
+} \
+\
+RTPDynamicProtocolHandler ff_g726_ ## bitrate ## _dynamic_handler = { \
+ .enc_name = "G726-" #bitrate, \
+ .codec_type = AVMEDIA_TYPE_AUDIO, \
+ .codec_id = CODEC_ID_ADPCM_G726, \
+ .init = g726_ ## bitrate ## _init, \
}
-static int g726_24_parse_sdp_line(AVFormatContext *s, int st_index,
- PayloadContext *data, const char *line)
-{
- AVStream *stream = s->streams[st_index];
- AVCodecContext *codec = stream->codec;
-
- codec->bit_rate = 24000;
-
- return 0;
-}
-
-static int g726_32_parse_sdp_line(AVFormatContext *s, int st_index,
- PayloadContext *data, const char *line)
-{
- AVStream *stream = s->streams[st_index];
- AVCodecContext *codec = stream->codec;
-
- codec->bit_rate = 32000;
-
- return 0;
-}
-
-static int g726_40_parse_sdp_line(AVFormatContext *s, int st_index,
- PayloadContext *data, const char *line)
-{
- AVStream *stream = s->streams[st_index];
- AVCodecContext *codec = stream->codec;
-
- codec->bit_rate = 40000;
-
- return 0;
-}
-
-RTPDynamicProtocolHandler ff_g726_16_dynamic_handler = {
- .enc_name = "G726-16",
- .codec_type = AVMEDIA_TYPE_AUDIO,
- .codec_id = CODEC_ID_ADPCM_G726,
- .parse_sdp_a_line = g726_16_parse_sdp_line,
-};
-
-RTPDynamicProtocolHandler ff_g726_24_dynamic_handler = {
- .enc_name = "G726-24",
- .codec_type = AVMEDIA_TYPE_AUDIO,
- .codec_id = CODEC_ID_ADPCM_G726,
- .parse_sdp_a_line = g726_24_parse_sdp_line,
-};
-
-RTPDynamicProtocolHandler ff_g726_32_dynamic_handler = {
- .enc_name = "G726-32",
- .codec_type = AVMEDIA_TYPE_AUDIO,
- .codec_id = CODEC_ID_ADPCM_G726,
- .parse_sdp_a_line = g726_32_parse_sdp_line,
-};
-
-RTPDynamicProtocolHandler ff_g726_40_dynamic_handler = {
- .enc_name = "G726-40",
- .codec_type = AVMEDIA_TYPE_AUDIO,
- .codec_id = CODEC_ID_ADPCM_G726,
- .parse_sdp_a_line = g726_40_parse_sdp_line,
-};
+RTP_G726_HANDLER(16);
+RTP_G726_HANDLER(24);
+RTP_G726_HANDLER(32);
+RTP_G726_HANDLER(40);