History

Merge commit 'd621b2f795684f7119057f986066060adbe84220'

* commit 'd621b2f795684f7119057f986066060adbe84220': lavf: Raw G.729 demuxer

Clément Bœsch committed 10 years ago

Commit 59547302 parents 28dac0d d621b2f1 file · +28 −26Browse files

Unified · Split

libavformat/g729dec.c+28−26
@@ -19,13 +19,15 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22−#include "avformat.h"
23−#include "internal.h"
2422 #include "libavutil/log.h"
2523 #include "libavutil/opt.h"
2624
25+#include "avformat.h"
26+#include "internal.h"
27+
2728 typedef struct G729DemuxerContext {
2829 AVClass *class;
30+
2931 int bit_rate;
3032 } G729DemuxerContext;
3133
@@ -38,49 +40,49 @@ static int g729_read_header(AVFormatContext *s) · 6 unmodified lines
3840 if (!st)
3941 return AVERROR(ENOMEM);
4042
41− st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
42− st->codecpar->codec_id = AV_CODEC_ID_G729;
43+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
44+ st->codecpar->codec_id = AV_CODEC_ID_G729;
4345 st->codecpar->sample_rate = 8000;
44− st->codecpar->channels = 1;
46+ st->codecpar->channels = 1;
4547
46− if (s1 && s1->bit_rate) {
48+ if (s1 && s1->bit_rate)
4749 s->bit_rate = s1->bit_rate;
48− }
49−
50− if (s->bit_rate == 0) {
51− av_log(s, AV_LOG_DEBUG, "No bitrate specified. Assuming 8000 b/s\n");
52− s->bit_rate = 8000;
53− }
5450
55− if (s->bit_rate == 6400) {
51+ switch(s->bit_rate) {
52+ case 6400:
5653 st->codecpar->block_align = 8;
57− } else if (s->bit_rate == 8000) {
54+ break;
55+ case 8000:
5856 st->codecpar->block_align = 10;
59− } else {
60− av_log(s, AV_LOG_ERROR, "Only 8000 b/s and 6400 b/s bitrates are supported. Provided: %"PRId64" b/s\n", (int64_t)s->bit_rate);
61− return AVERROR_INVALIDDATA;
57+ break;
58+ default:
59+ av_log(s, AV_LOG_ERROR, "Invalid bit_rate value %d. "
60+ "Only 6400 and 8000 b/s are supported.", s->bit_rate);
61+ return AVERROR(EINVAL);
6262 }
6363
64− avpriv_set_pts_info(st, st->codecpar->block_align << 3, 1, st->codecpar->sample_rate);
64+ avpriv_set_pts_info(st, st->codecpar->block_align << 3, 1,
65+ st->codecpar->sample_rate);
66+
6567 return 0;
6668 }
69+
6770 static int g729_read_packet(AVFormatContext *s, AVPacket *pkt)
6871 {
69− int ret;
70−
71− ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
72−
73− pkt->stream_index = 0;
72+ AVStream *st = s->streams[0];
73+ int ret = av_get_packet(s->pb, pkt, st->codecpar->block_align);
7474 if (ret < 0)
7575 return ret;
7676
77− pkt->dts = pkt->pts = pkt->pos / s->streams[0]->codecpar->block_align;
77+ pkt->stream_index = 0;
78+ pkt->dts = pkt->pts = pkt->pos / st->codecpar->block_align;
7879
79− return ret;
80+ return 0;
8081 }
8182
83+#define OFFSET(x) offsetof(G729DemuxerContext, x)
8284 static const AVOption g729_options[] = {
83− { "bit_rate", "", offsetof(G729DemuxerContext, bit_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
85+ { "bit_rate", "", OFFSET(bit_rate), AV_OPT_TYPE_INT, { .i64 = 8000 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
8486 { NULL },
8587 };
8688

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t