Merge commit 'd621b2f795684f7119057f986066060adbe84220'
* commit 'd621b2f795684f7119057f986066060adbe84220': lavf: Raw G.729 demuxer Merged-by: Clément Bœsch <clement@stupeflix.com>
This commit is contained in:
@ -19,13 +19,15 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avformat.h"
|
|
||||||
#include "internal.h"
|
|
||||||
#include "libavutil/log.h"
|
#include "libavutil/log.h"
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
|
|
||||||
|
#include "avformat.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
typedef struct G729DemuxerContext {
|
typedef struct G729DemuxerContext {
|
||||||
AVClass *class;
|
AVClass *class;
|
||||||
|
|
||||||
int bit_rate;
|
int bit_rate;
|
||||||
} G729DemuxerContext;
|
} G729DemuxerContext;
|
||||||
|
|
||||||
@ -43,44 +45,44 @@ static int g729_read_header(AVFormatContext *s)
|
|||||||
st->codecpar->sample_rate = 8000;
|
st->codecpar->sample_rate = 8000;
|
||||||
st->codecpar->channels = 1;
|
st->codecpar->channels = 1;
|
||||||
|
|
||||||
if (s1 && s1->bit_rate) {
|
if (s1 && s1->bit_rate)
|
||||||
s->bit_rate = s1->bit_rate;
|
s->bit_rate = s1->bit_rate;
|
||||||
}
|
|
||||||
|
|
||||||
if (s->bit_rate == 0) {
|
switch(s->bit_rate) {
|
||||||
av_log(s, AV_LOG_DEBUG, "No bitrate specified. Assuming 8000 b/s\n");
|
case 6400:
|
||||||
s->bit_rate = 8000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->bit_rate == 6400) {
|
|
||||||
st->codecpar->block_align = 8;
|
st->codecpar->block_align = 8;
|
||||||
} else if (s->bit_rate == 8000) {
|
break;
|
||||||
|
case 8000:
|
||||||
st->codecpar->block_align = 10;
|
st->codecpar->block_align = 10;
|
||||||
} else {
|
break;
|
||||||
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);
|
default:
|
||||||
return AVERROR_INVALIDDATA;
|
av_log(s, AV_LOG_ERROR, "Invalid bit_rate value %d. "
|
||||||
|
"Only 6400 and 8000 b/s are supported.", s->bit_rate);
|
||||||
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
avpriv_set_pts_info(st, st->codecpar->block_align << 3, 1, st->codecpar->sample_rate);
|
avpriv_set_pts_info(st, st->codecpar->block_align << 3, 1,
|
||||||
|
st->codecpar->sample_rate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int g729_read_packet(AVFormatContext *s, AVPacket *pkt)
|
static int g729_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
int ret;
|
AVStream *st = s->streams[0];
|
||||||
|
int ret = av_get_packet(s->pb, pkt, st->codecpar->block_align);
|
||||||
ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
|
|
||||||
|
|
||||||
pkt->stream_index = 0;
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
pkt->dts = pkt->pts = pkt->pos / s->streams[0]->codecpar->block_align;
|
pkt->stream_index = 0;
|
||||||
|
pkt->dts = pkt->pts = pkt->pos / st->codecpar->block_align;
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OFFSET(x) offsetof(G729DemuxerContext, x)
|
||||||
static const AVOption g729_options[] = {
|
static const AVOption g729_options[] = {
|
||||||
{ "bit_rate", "", offsetof(G729DemuxerContext, bit_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
|
{ "bit_rate", "", OFFSET(bit_rate), AV_OPT_TYPE_INT, { .i64 = 8000 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user