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
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */20 */
21 21
22#include "avformat.h"
23#include "internal.h"
24#include "libavutil/log.h"22#include "libavutil/log.h"
25#include "libavutil/opt.h"23#include "libavutil/opt.h"
26 24
25#include "avformat.h"
26#include "internal.h"
27
27typedef struct G729DemuxerContext {28typedef struct G729DemuxerContext {
28 AVClass *class;29 AVClass *class;
30
29 int bit_rate;31 int bit_rate;
30} G729DemuxerContext;32} G729DemuxerContext;
31 33
@@ -38,49 +40,49 @@ static int g729_read_header(AVFormatContext *s) · 6 unmodified lines
38 if (!st)40 if (!st)
39 return AVERROR(ENOMEM);41 return AVERROR(ENOMEM);
40 42
41 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;43 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
42 st->codecpar->codec_id = AV_CODEC_ID_G729;44 st->codecpar->codec_id = AV_CODEC_ID_G729;
43 st->codecpar->sample_rate = 8000;45 st->codecpar->sample_rate = 8000;
44 st->codecpar->channels = 1;46 st->codecpar->channels = 1;
45 47
46 if (s1 && s1->bit_rate) {48 if (s1 && s1->bit_rate)
47 s->bit_rate = s1->bit_rate;49 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 }
54 50
55 if (s->bit_rate == 6400) {51 switch(s->bit_rate) {
52 case 6400:
56 st->codecpar->block_align = 8;53 st->codecpar->block_align = 8;
57 } else if (s->bit_rate == 8000) {54 break;
55 case 8000:
58 st->codecpar->block_align = 10;56 st->codecpar->block_align = 10;
59 } else {57 break;
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);58 default:
61 return AVERROR_INVALIDDATA;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);
62 }62 }
63 63
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
65 return 0;67 return 0;
66}68}
69
67static int g729_read_packet(AVFormatContext *s, AVPacket *pkt)70static int g729_read_packet(AVFormatContext *s, AVPacket *pkt)
68{71{
69 int ret;72 AVStream *st = s->streams[0];
70 73 int ret = av_get_packet(s->pb, pkt, st->codecpar->block_align);
71 ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
72
73 pkt->stream_index = 0;
74 if (ret < 0)74 if (ret < 0)
75 return ret;75 return ret;
76 76
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;
78 79
79 return ret;80 return 0;
80}81}
81 82
83#define OFFSET(x) offsetof(G729DemuxerContext, x)
82static const AVOption g729_options[] = {84static 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 },
84 { NULL },86 { NULL },
85};87};
86 88

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