mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-01-06 22:25:36 +01:00
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
lavf: replace AVStream.codec with AVStream.codecpar
This has been a HUGE effort from:
- Derek Buitenhuis <derek.buitenhuis@gmail.com>
- Hendrik Leppkes <h.leppkes@gmail.com>
- wm4 <nfxjfg@googlemail.com>
- Clément Bœsch <clement@stupeflix.com>
- James Almer <jamrial@gmail.com>
- Michael Niedermayer <michael@niedermayer.cc>
- Rostislav Pehlivanov <atomnuker@gmail.com>
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
@@ -145,34 +145,34 @@ static int rpl_read_header(AVFormatContext *s)
|
||||
vst = avformat_new_stream(s, NULL);
|
||||
if (!vst)
|
||||
return AVERROR(ENOMEM);
|
||||
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
vst->codec->codec_tag = read_line_and_int(pb, &error); // video format
|
||||
vst->codec->width = read_line_and_int(pb, &error); // video width
|
||||
vst->codec->height = read_line_and_int(pb, &error); // video height
|
||||
vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample
|
||||
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
vst->codecpar->codec_tag = read_line_and_int(pb, &error); // video format
|
||||
vst->codecpar->width = read_line_and_int(pb, &error); // video width
|
||||
vst->codecpar->height = read_line_and_int(pb, &error); // video height
|
||||
vst->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample
|
||||
error |= read_line(pb, line, sizeof(line)); // video frames per second
|
||||
fps = read_fps(line, &error);
|
||||
avpriv_set_pts_info(vst, 32, fps.den, fps.num);
|
||||
|
||||
// Figure out the video codec
|
||||
switch (vst->codec->codec_tag) {
|
||||
switch (vst->codecpar->codec_tag) {
|
||||
#if 0
|
||||
case 122:
|
||||
vst->codec->codec_id = AV_CODEC_ID_ESCAPE122;
|
||||
vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE122;
|
||||
break;
|
||||
#endif
|
||||
case 124:
|
||||
vst->codec->codec_id = AV_CODEC_ID_ESCAPE124;
|
||||
vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE124;
|
||||
// The header is wrong here, at least sometimes
|
||||
vst->codec->bits_per_coded_sample = 16;
|
||||
vst->codecpar->bits_per_coded_sample = 16;
|
||||
break;
|
||||
case 130:
|
||||
vst->codec->codec_id = AV_CODEC_ID_ESCAPE130;
|
||||
vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE130;
|
||||
break;
|
||||
default:
|
||||
avpriv_report_missing_feature(s, "Video format %i",
|
||||
vst->codec->codec_tag);
|
||||
vst->codec->codec_id = AV_CODEC_ID_NONE;
|
||||
vst->codecpar->codec_tag);
|
||||
vst->codecpar->codec_id = AV_CODEC_ID_NONE;
|
||||
}
|
||||
|
||||
// Audio headers
|
||||
@@ -184,57 +184,57 @@ static int rpl_read_header(AVFormatContext *s)
|
||||
ast = avformat_new_stream(s, NULL);
|
||||
if (!ast)
|
||||
return AVERROR(ENOMEM);
|
||||
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
ast->codec->codec_tag = audio_format;
|
||||
ast->codec->sample_rate = read_line_and_int(pb, &error); // audio bitrate
|
||||
ast->codec->channels = read_line_and_int(pb, &error); // number of audio channels
|
||||
ast->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // audio bits per sample
|
||||
ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
ast->codecpar->codec_tag = audio_format;
|
||||
ast->codecpar->sample_rate = read_line_and_int(pb, &error); // audio bitrate
|
||||
ast->codecpar->channels = read_line_and_int(pb, &error); // number of audio channels
|
||||
ast->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error); // audio bits per sample
|
||||
// At least one sample uses 0 for ADPCM, which is really 4 bits
|
||||
// per sample.
|
||||
if (ast->codec->bits_per_coded_sample == 0)
|
||||
ast->codec->bits_per_coded_sample = 4;
|
||||
if (ast->codecpar->bits_per_coded_sample == 0)
|
||||
ast->codecpar->bits_per_coded_sample = 4;
|
||||
|
||||
ast->codec->bit_rate = ast->codec->sample_rate *
|
||||
ast->codec->bits_per_coded_sample *
|
||||
ast->codec->channels;
|
||||
ast->codecpar->bit_rate = ast->codecpar->sample_rate *
|
||||
ast->codecpar->bits_per_coded_sample *
|
||||
ast->codecpar->channels;
|
||||
|
||||
ast->codec->codec_id = AV_CODEC_ID_NONE;
|
||||
ast->codecpar->codec_id = AV_CODEC_ID_NONE;
|
||||
switch (audio_format) {
|
||||
case 1:
|
||||
if (ast->codec->bits_per_coded_sample == 16) {
|
||||
if (ast->codecpar->bits_per_coded_sample == 16) {
|
||||
// 16-bit audio is always signed
|
||||
ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
|
||||
ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
|
||||
break;
|
||||
}
|
||||
// There are some other formats listed as legal per the spec;
|
||||
// samples needed.
|
||||
break;
|
||||
case 101:
|
||||
if (ast->codec->bits_per_coded_sample == 8) {
|
||||
if (ast->codecpar->bits_per_coded_sample == 8) {
|
||||
// The samples with this kind of audio that I have
|
||||
// are all unsigned.
|
||||
ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
|
||||
ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
|
||||
break;
|
||||
} else if (ast->codec->bits_per_coded_sample == 4) {
|
||||
ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD;
|
||||
} else if (ast->codecpar->bits_per_coded_sample == 4) {
|
||||
ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (ast->codec->codec_id == AV_CODEC_ID_NONE)
|
||||
if (ast->codecpar->codec_id == AV_CODEC_ID_NONE)
|
||||
avpriv_request_sample(s, "Audio format %"PRId32,
|
||||
audio_format);
|
||||
avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);
|
||||
avpriv_set_pts_info(ast, 32, 1, ast->codecpar->bit_rate);
|
||||
} else {
|
||||
for (i = 0; i < 3; i++)
|
||||
error |= read_line(pb, line, sizeof(line));
|
||||
}
|
||||
|
||||
rpl->frames_per_chunk = read_line_and_int(pb, &error); // video frames per chunk
|
||||
if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124)
|
||||
if (rpl->frames_per_chunk > 1 && vst->codecpar->codec_tag != 124)
|
||||
av_log(s, AV_LOG_WARNING,
|
||||
"Don't know how to split frames for video format %i. "
|
||||
"Video stream will be broken!\n", vst->codec->codec_tag);
|
||||
"Video stream will be broken!\n", vst->codecpar->codec_tag);
|
||||
|
||||
number_of_chunks = read_line_and_int(pb, &error); // number of chunks in the file
|
||||
// The number in the header is actually the index of the last chunk.
|
||||
@@ -296,8 +296,8 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if (avio_seek(pb, index_entry->pos, SEEK_SET) < 0)
|
||||
return AVERROR(EIO);
|
||||
|
||||
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||
stream->codec->codec_tag == 124) {
|
||||
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||
stream->codecpar->codec_tag == 124) {
|
||||
// We have to split Escape 124 frames because there are
|
||||
// multiple frames per chunk in Escape 124 samples.
|
||||
uint32_t frame_size;
|
||||
@@ -332,7 +332,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
|
||||
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
// frames_per_chunk should always be one here; the header
|
||||
// parsing will warn if it isn't.
|
||||
pkt->duration = rpl->frames_per_chunk;
|
||||
|
||||
Reference in New Issue
Block a user