Commit 01a39a97 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '55ddd700'

* commit '55ddd700':
  Silicon Graphics Movie demuxer

Conflicts:
	Changelog
	libavformat/mvdec.c
	libavformat/version.h

See: 6fb40779Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 0c67ef27 55ddd700
...@@ -246,8 +246,8 @@ OBJS-$(CONFIG_MPL2_DEMUXER) += mpl2dec.o subtitles.o ...@@ -246,8 +246,8 @@ OBJS-$(CONFIG_MPL2_DEMUXER) += mpl2dec.o subtitles.o
OBJS-$(CONFIG_MPSUB_DEMUXER) += mpsubdec.o subtitles.o OBJS-$(CONFIG_MPSUB_DEMUXER) += mpsubdec.o subtitles.o
OBJS-$(CONFIG_MSNWC_TCP_DEMUXER) += msnwc_tcp.o OBJS-$(CONFIG_MSNWC_TCP_DEMUXER) += msnwc_tcp.o
OBJS-$(CONFIG_MTV_DEMUXER) += mtv.o OBJS-$(CONFIG_MTV_DEMUXER) += mtv.o
OBJS-$(CONFIG_MVI_DEMUXER) += mvi.o
OBJS-$(CONFIG_MV_DEMUXER) += mvdec.o OBJS-$(CONFIG_MV_DEMUXER) += mvdec.o
OBJS-$(CONFIG_MVI_DEMUXER) += mvi.o
OBJS-$(CONFIG_MXF_DEMUXER) += mxfdec.o mxf.o OBJS-$(CONFIG_MXF_DEMUXER) += mxfdec.o mxf.o
OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o audiointerleave.o OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o audiointerleave.o
OBJS-$(CONFIG_MXG_DEMUXER) += mxg.o OBJS-$(CONFIG_MXG_DEMUXER) += mxg.o
......
...@@ -24,48 +24,55 @@ ...@@ -24,48 +24,55 @@
* Silicon Graphics Movie demuxer * Silicon Graphics Movie demuxer
*/ */
#include "libavutil/channel_layout.h"
#include "libavutil/eval.h" #include "libavutil/eval.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/rational.h" #include "libavutil/rational.h"
#include "avformat.h" #include "avformat.h"
#include "internal.h" #include "internal.h"
typedef struct { typedef struct MvContext {
int nb_video_tracks; int nb_video_tracks;
int nb_audio_tracks; int nb_audio_tracks;
int eof_count; /**< number of streams that have finished */ int eof_count; ///< number of streams that have finished
int stream_index; /**< current stream index */ int stream_index; ///< current stream index
int frame[2]; /**< frame nb for current stream */ int frame[2]; ///< frame nb for current stream
int acompression; ///< compression level for audio stream
int aformat; ///< audio format
} MvContext; } MvContext;
#define AUDIO_FORMAT_SIGNED 401 #define AUDIO_FORMAT_SIGNED 401
static int mv_probe(AVProbeData *p) static int mv_probe(AVProbeData *p)
{ {
if (AV_RB32(p->buf) == MKBETAG('M','O','V','I') && AV_RB16(p->buf + 4) < 3) if (AV_RB32(p->buf) == MKBETAG('M', 'O', 'V', 'I') &&
AV_RB16(p->buf + 4) < 3)
return AVPROBE_SCORE_MAX; return AVPROBE_SCORE_MAX;
return 0; return 0;
} }
static char * var_read_string(AVIOContext *pb, int size) static char *var_read_string(AVIOContext *pb, int size)
{ {
char *str = av_malloc(size + 1);
int n; int n;
char *str = av_malloc(size + 1);
if (!str) if (!str)
return NULL; return NULL;
n = avio_get_str(pb, size, str, size + 1); n = avio_get_str(pb, size, str, size + 1);
if (n < size) if (n < size)
avio_skip(pb, size - n); avio_skip(pb, size - n);
return str; return str;
} }
static int var_read_int(AVIOContext *pb, int size) static int var_read_int(AVIOContext *pb, int size)
{ {
int v; int v;
char * s = var_read_string(pb, size); char *s = var_read_string(pb, size);
if (!s || sscanf(s, "%d", &v) != 1) if (!s)
v = 0; return 0;
v = strtol(s, NULL, 10);
av_free(s); av_free(s);
return v; return v;
} }
...@@ -73,9 +80,9 @@ static int var_read_int(AVIOContext *pb, int size) ...@@ -73,9 +80,9 @@ static int var_read_int(AVIOContext *pb, int size)
static AVRational var_read_float(AVIOContext *pb, int size) static AVRational var_read_float(AVIOContext *pb, int size)
{ {
AVRational v; AVRational v;
char * s = var_read_string(pb, size); char *s = var_read_string(pb, size);
if (!s) if (!s)
return (AVRational){0, 0}; return (AVRational) { 0, 0 };
v = av_d2q(av_strtod(s, NULL), INT_MAX); v = av_d2q(av_strtod(s, NULL), INT_MAX);
av_free(s); av_free(s);
return v; return v;
...@@ -88,13 +95,15 @@ static void var_read_metadata(AVFormatContext *avctx, const char *tag, int size) ...@@ -88,13 +95,15 @@ static void var_read_metadata(AVFormatContext *avctx, const char *tag, int size)
av_dict_set(&avctx->metadata, tag, value, AV_DICT_DONT_STRDUP_VAL); av_dict_set(&avctx->metadata, tag, value, AV_DICT_DONT_STRDUP_VAL);
} }
static int set_channels(AVFormatContext *avctx, AVStream *st, int channels) { static int set_channels(AVFormatContext *avctx, AVStream *st, int channels)
{
if (channels <= 0) { if (channels <= 0) {
av_log(avctx, AV_LOG_ERROR, "Channel count %d invalid\n", channels); av_log(avctx, AV_LOG_ERROR, "Channel count %d invalid.\n", channels);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
st->codec->channels = channels; st->codec->channels = channels;
st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO
: AV_CH_LAYOUT_STEREO;
return 0; return 0;
} }
...@@ -102,7 +111,8 @@ static int set_channels(AVFormatContext *avctx, AVStream *st, int channels) { ...@@ -102,7 +111,8 @@ static int set_channels(AVFormatContext *avctx, AVStream *st, int channels) {
* Parse global variable * Parse global variable
* @return < 0 if unknown * @return < 0 if unknown
*/ */
static int parse_global_var(AVFormatContext *avctx, AVStream *st, const char *name, int size) static int parse_global_var(AVFormatContext *avctx, AVStream *st,
const char *name, int size)
{ {
MvContext *mv = avctx->priv_data; MvContext *mv = avctx->priv_data;
AVIOContext *pb = avctx->pb; AVIOContext *pb = avctx->pb;
...@@ -112,10 +122,11 @@ static int parse_global_var(AVFormatContext *avctx, AVStream *st, const char *na ...@@ -112,10 +122,11 @@ static int parse_global_var(AVFormatContext *avctx, AVStream *st, const char *na
mv->nb_audio_tracks = var_read_int(pb, size); mv->nb_audio_tracks = var_read_int(pb, size);
} else if (!strcmp(name, "COMMENT") || !strcmp(name, "TITLE")) { } else if (!strcmp(name, "COMMENT") || !strcmp(name, "TITLE")) {
var_read_metadata(avctx, name, size); var_read_metadata(avctx, name, size);
} else if (!strcmp(name, "LOOP_MODE") || !strcmp(name, "NUM_LOOPS") || !strcmp(name, "OPTIMIZED")) { } else if (!strcmp(name, "LOOP_MODE") || !strcmp(name, "NUM_LOOPS") ||
!strcmp(name, "OPTIMIZED")) {
avio_skip(pb, size); // ignore avio_skip(pb, size); // ignore
} else } else
return -1; return AVERROR_INVALIDDATA;
return 0; return 0;
} }
...@@ -124,15 +135,17 @@ static int parse_global_var(AVFormatContext *avctx, AVStream *st, const char *na ...@@ -124,15 +135,17 @@ static int parse_global_var(AVFormatContext *avctx, AVStream *st, const char *na
* Parse audio variable * Parse audio variable
* @return < 0 if unknown * @return < 0 if unknown
*/ */
static int parse_audio_var(AVFormatContext *avctx, AVStream *st, const char *name, int size) static int parse_audio_var(AVFormatContext *avctx, AVStream *st,
const char *name, int size)
{ {
MvContext *mv = avctx->priv_data;
AVIOContext *pb = avctx->pb; AVIOContext *pb = avctx->pb;
if (!strcmp(name, "__DIR_COUNT")) { if (!strcmp(name, "__DIR_COUNT")) {
st->nb_frames = var_read_int(pb, size); st->nb_frames = var_read_int(pb, size);
} else if (!strcmp(name, "AUDIO_FORMAT")) { } else if (!strcmp(name, "AUDIO_FORMAT")) {
st->codec->codec_id = var_read_int(pb, size); mv->aformat = var_read_int(pb, size);
} else if (!strcmp(name, "COMPRESSION")) { } else if (!strcmp(name, "COMPRESSION")) {
st->codec->codec_tag = var_read_int(pb, size); mv->acompression = var_read_int(pb, size);
} else if (!strcmp(name, "DEFAULT_VOL")) { } else if (!strcmp(name, "DEFAULT_VOL")) {
var_read_metadata(avctx, name, size); var_read_metadata(avctx, name, size);
} else if (!strcmp(name, "NUM_CHANNELS")) { } else if (!strcmp(name, "NUM_CHANNELS")) {
...@@ -143,7 +156,8 @@ static int parse_audio_var(AVFormatContext *avctx, AVStream *st, const char *nam ...@@ -143,7 +156,8 @@ static int parse_audio_var(AVFormatContext *avctx, AVStream *st, const char *nam
} else if (!strcmp(name, "SAMPLE_WIDTH")) { } else if (!strcmp(name, "SAMPLE_WIDTH")) {
st->codec->bits_per_coded_sample = var_read_int(pb, size) * 8; st->codec->bits_per_coded_sample = var_read_int(pb, size) * 8;
} else } else
return -1; return AVERROR_INVALIDDATA;
return 0; return 0;
} }
...@@ -151,13 +165,14 @@ static int parse_audio_var(AVFormatContext *avctx, AVStream *st, const char *nam ...@@ -151,13 +165,14 @@ static int parse_audio_var(AVFormatContext *avctx, AVStream *st, const char *nam
* Parse video variable * Parse video variable
* @return < 0 if unknown * @return < 0 if unknown
*/ */
static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *name, int size) static int parse_video_var(AVFormatContext *avctx, AVStream *st,
const char *name, int size)
{ {
AVIOContext *pb = avctx->pb; AVIOContext *pb = avctx->pb;
if (!strcmp(name, "__DIR_COUNT")) { if (!strcmp(name, "__DIR_COUNT")) {
st->nb_frames = st->duration = var_read_int(pb, size); st->nb_frames = st->duration = var_read_int(pb, size);
} else if (!strcmp(name, "COMPRESSION")) { } else if (!strcmp(name, "COMPRESSION")) {
char * str = var_read_string(pb, size); char *str = var_read_string(pb, size);
if (!str) if (!str)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (!strcmp(str, "1")) { if (!strcmp(str, "1")) {
...@@ -172,35 +187,40 @@ static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *nam ...@@ -172,35 +187,40 @@ static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *nam
} else if (!strcmp(str, "MVC2")) { } else if (!strcmp(str, "MVC2")) {
st->codec->codec_id = AV_CODEC_ID_MVC2; st->codec->codec_id = AV_CODEC_ID_MVC2;
} else { } else {
avpriv_request_sample(avctx, "video compression %s", str); avpriv_request_sample(avctx, "Video compression %s", str);
} }
av_free(str); av_free(str);
} else if (!strcmp(name, "FPS")) { } else if (!strcmp(name, "FPS")) {
AVRational fps = var_read_float(pb, size); AVRational fps = var_read_float(pb, size);
avpriv_set_pts_info(st, 64, fps.den, fps.num); avpriv_set_pts_info(st, 64, fps.den, fps.num);
st->avg_frame_rate = fps;
} else if (!strcmp(name, "HEIGHT")) { } else if (!strcmp(name, "HEIGHT")) {
st->codec->height = var_read_int(pb, size); st->codec->height = var_read_int(pb, size);
} else if (!strcmp(name, "PIXEL_ASPECT")) { } else if (!strcmp(name, "PIXEL_ASPECT")) {
st->sample_aspect_ratio = var_read_float(pb, size); st->sample_aspect_ratio = var_read_float(pb, size);
av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den,
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, INT_MAX); st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
INT_MAX);
} else if (!strcmp(name, "WIDTH")) { } else if (!strcmp(name, "WIDTH")) {
st->codec->width = var_read_int(pb, size); st->codec->width = var_read_int(pb, size);
} else if (!strcmp(name, "ORIENTATION")) { } else if (!strcmp(name, "ORIENTATION")) {
if (var_read_int(pb, size) == 1101) { if (var_read_int(pb, size) == 1101) {
st->codec->extradata = av_strdup("BottomUp"); st->codec->extradata = av_strdup("BottomUp");
st->codec->extradata_size = 9; st->codec->extradata_size = 9;
} }
} else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) { } else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) {
var_read_metadata(avctx, name, size); var_read_metadata(avctx, name, size);
} else if (!strcmp(name, "INTERLACING") || !strcmp(name, "PACKING")) { } else if (!strcmp(name, "INTERLACING") || !strcmp(name, "PACKING")) {
avio_skip(pb, size); // ignore avio_skip(pb, size); // ignore
} else } else
return -1; return AVERROR_INVALIDDATA;
return 0; return 0;
} }
static void read_table(AVFormatContext *avctx, AVStream *st, int (*parse)(AVFormatContext *avctx, AVStream *st, const char *name, int size)) static void read_table(AVFormatContext *avctx, AVStream *st,
int (*parse)(AVFormatContext *avctx, AVStream *st,
const char *name, int size))
{ {
int count, i; int count, i;
AVIOContext *pb = avctx->pb; AVIOContext *pb = avctx->pb;
...@@ -214,7 +234,7 @@ static void read_table(AVFormatContext *avctx, AVStream *st, int (*parse)(AVForm ...@@ -214,7 +234,7 @@ static void read_table(AVFormatContext *avctx, AVStream *st, int (*parse)(AVForm
name[sizeof(name) - 1] = 0; name[sizeof(name) - 1] = 0;
size = avio_rb32(pb); size = avio_rb32(pb);
if (parse(avctx, st, name, size) < 0) { if (parse(avctx, st, name, size) < 0) {
avpriv_request_sample(avctx, "variable %s", name); avpriv_request_sample(avctx, "Variable %s", name);
avio_skip(pb, size); avio_skip(pb, size);
} }
} }
...@@ -253,7 +273,7 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -253,7 +273,7 @@ static int mv_read_header(AVFormatContext *avctx)
avio_skip(pb, 22); avio_skip(pb, 22);
/* allocate audio track first to prevent unnecessary seeking /* allocate audio track first to prevent unnecessary seeking
(audio packet always precede video packet for a given frame) */ * (audio packet always precede video packet for a given frame) */
ast = avformat_new_stream(avctx, NULL); ast = avformat_new_stream(avctx, NULL);
if (!ast) if (!ast)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
...@@ -261,9 +281,10 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -261,9 +281,10 @@ static int mv_read_header(AVFormatContext *avctx)
vst = avformat_new_stream(avctx, NULL); vst = avformat_new_stream(avctx, NULL);
if (!vst) if (!vst)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
avpriv_set_pts_info(vst, 64, 1, 15); avpriv_set_pts_info(vst, 64, 1, 15);
vst->nb_frames = avio_rb32(pb); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->avg_frame_rate = av_inv_q(vst->time_base);
vst->nb_frames = avio_rb32(pb);
v = avio_rb32(pb); v = avio_rb32(pb);
switch (v) { switch (v) {
case 1: case 1:
...@@ -274,7 +295,7 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -274,7 +295,7 @@ static int mv_read_header(AVFormatContext *avctx)
vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO; vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
break; break;
default: default:
avpriv_request_sample(avctx, "video compression %i", v); avpriv_request_sample(avctx, "Video compression %i", v);
break; break;
} }
vst->codec->codec_tag = 0; vst->codec->codec_tag = 0;
...@@ -282,9 +303,9 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -282,9 +303,9 @@ static int mv_read_header(AVFormatContext *avctx)
vst->codec->height = avio_rb32(pb); vst->codec->height = avio_rb32(pb);
avio_skip(pb, 12); avio_skip(pb, 12);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->nb_frames = vst->nb_frames; ast->nb_frames = vst->nb_frames;
ast->codec->sample_rate = avio_rb32(pb); ast->codec->sample_rate = avio_rb32(pb);
avpriv_set_pts_info(ast, 33, 1, ast->codec->sample_rate); avpriv_set_pts_info(ast, 33, 1, ast->codec->sample_rate);
if (set_channels(avctx, ast, avio_rb32(pb)) < 0) if (set_channels(avctx, ast, avio_rb32(pb)) < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -293,7 +314,7 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -293,7 +314,7 @@ static int mv_read_header(AVFormatContext *avctx)
if (v == AUDIO_FORMAT_SIGNED) { if (v == AUDIO_FORMAT_SIGNED) {
ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE; ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
} else { } else {
avpriv_request_sample(avctx, "audio compression (format %i)", v); avpriv_request_sample(avctx, "Audio compression (format %i)", v);
} }
avio_skip(pb, 12); avio_skip(pb, 12);
...@@ -307,8 +328,8 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -307,8 +328,8 @@ static int mv_read_header(AVFormatContext *avctx)
uint32_t asize = avio_rb32(pb); uint32_t asize = avio_rb32(pb);
uint32_t vsize = avio_rb32(pb); uint32_t vsize = avio_rb32(pb);
avio_skip(pb, 8); avio_skip(pb, 8);
av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME); av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME);
av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME); av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME);
timestamp += asize / (ast->codec->channels * 2); timestamp += asize / (ast->codec->channels * 2);
} }
} else if (!version && avio_rb16(pb) == 3) { } else if (!version && avio_rb16(pb) == 3) {
...@@ -317,31 +338,33 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -317,31 +338,33 @@ static int mv_read_header(AVFormatContext *avctx)
read_table(avctx, NULL, parse_global_var); read_table(avctx, NULL, parse_global_var);
if (mv->nb_audio_tracks > 1) { if (mv->nb_audio_tracks > 1) {
avpriv_request_sample(avctx, "multiple audio streams support"); avpriv_request_sample(avctx, "Multiple audio streams support");
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} else if (mv->nb_audio_tracks) { } else if (mv->nb_audio_tracks) {
ast = avformat_new_stream(avctx, NULL); ast = avformat_new_stream(avctx, NULL);
if (!ast) if (!ast)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
/* temporarily store compression value in codec_tag; format value in codec_id */
read_table(avctx, ast, parse_audio_var); read_table(avctx, ast, parse_audio_var);
if (ast->codec->codec_tag == 100 && ast->codec->codec_id == AUDIO_FORMAT_SIGNED && ast->codec->bits_per_coded_sample == 16) { if (mv->acompression == 100 &&
mv->aformat == AUDIO_FORMAT_SIGNED &&
ast->codec->bits_per_coded_sample == 16) {
ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE; ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
} else { } else {
avpriv_request_sample(avctx, "audio compression %i (format %i, width %i)", avpriv_request_sample(avctx,
ast->codec->codec_tag, ast->codec->codec_id, ast->codec->bits_per_coded_sample); "Audio compression %i (format %i, sr %i)",
mv->acompression, mv->aformat,
ast->codec->bits_per_coded_sample);
ast->codec->codec_id = AV_CODEC_ID_NONE; ast->codec->codec_id = AV_CODEC_ID_NONE;
} }
ast->codec->codec_tag = 0;
if (ast->codec->channels <= 0) { if (ast->codec->channels <= 0) {
av_log(avctx, AV_LOG_ERROR, "No valid channel count found\n"); av_log(avctx, AV_LOG_ERROR, "No valid channel count found.\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
} }
if (mv->nb_video_tracks > 1) { if (mv->nb_video_tracks > 1) {
avpriv_request_sample(avctx, "multiple video streams support"); avpriv_request_sample(avctx, "Multiple video streams support");
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} else if (mv->nb_video_tracks) { } else if (mv->nb_video_tracks) {
vst = avformat_new_stream(avctx, NULL); vst = avformat_new_stream(avctx, NULL);
...@@ -357,7 +380,7 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -357,7 +380,7 @@ static int mv_read_header(AVFormatContext *avctx)
if (mv->nb_video_tracks) if (mv->nb_video_tracks)
read_index(pb, vst); read_index(pb, vst);
} else { } else {
avpriv_request_sample(avctx, "version %i", version); avpriv_request_sample(avctx, "Version %i", version);
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
...@@ -374,9 +397,9 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt) ...@@ -374,9 +397,9 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
int ret; int ret;
uint64_t pos; uint64_t pos;
if (frame < st->nb_index_entries) { if (frame < st->nb_index_entries) {
index = &st->index_entries[frame]; index = &st->index_entries[frame];
pos = avio_tell(pb); pos = avio_tell(pb);
if (index->pos > pos) if (index->pos > pos)
avio_skip(pb, index->pos - pos); avio_skip(pb, index->pos - pos);
else if (index->pos < pos) { else if (index->pos < pos) {
...@@ -391,8 +414,8 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt) ...@@ -391,8 +414,8 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
return ret; return ret;
pkt->stream_index = mv->stream_index; pkt->stream_index = mv->stream_index;
pkt->pts = index->timestamp; pkt->pts = index->timestamp;
pkt->flags |= AV_PKT_FLAG_KEY; pkt->flags |= AV_PKT_FLAG_KEY;
mv->frame[mv->stream_index]++; mv->frame[mv->stream_index]++;
mv->eof_count = 0; mv->eof_count = 0;
...@@ -400,6 +423,9 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt) ...@@ -400,6 +423,9 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
mv->eof_count++; mv->eof_count++;
if (mv->eof_count >= avctx->nb_streams) if (mv->eof_count >= avctx->nb_streams)
return AVERROR_EOF; return AVERROR_EOF;
// avoid returning 0 without a packet
return AVERROR(EAGAIN);
} }
mv->stream_index++; mv->stream_index++;
...@@ -409,7 +435,8 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt) ...@@ -409,7 +435,8 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
return 0; return 0;
} }
static int mv_read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags) static int mv_read_seek(AVFormatContext *avctx, int stream_index,
int64_t timestamp, int flags)
{ {
MvContext *mv = avctx->priv_data; MvContext *mv = avctx->priv_data;
AVStream *st = avctx->streams[stream_index]; AVStream *st = avctx->streams[stream_index];
...@@ -423,7 +450,7 @@ static int mv_read_seek(AVFormatContext *avctx, int stream_index, int64_t timest ...@@ -423,7 +450,7 @@ static int mv_read_seek(AVFormatContext *avctx, int stream_index, int64_t timest
frame = av_index_search_timestamp(st, timestamp, flags); frame = av_index_search_timestamp(st, timestamp, flags);
if (frame < 0) if (frame < 0)
return -1; return AVERROR_INVALIDDATA;
for (i = 0; i < avctx->nb_streams; i++) for (i = 0; i < avctx->nb_streams; i++)
mv->frame[i] = frame; mv->frame[i] = frame;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 55 #define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR 37 #define LIBAVFORMAT_VERSION_MINOR 37
#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \ LIBAVFORMAT_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment