AVIDEC: use_odmc demuxer specific option. (mostly an exmaple for demuxer specific options)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-04-30 21:37:11 +02:00
parent 492026209b
commit ffdc49df25
1 changed files with 21 additions and 1 deletions

View File

@ -25,6 +25,7 @@
#include <strings.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/bswap.h"
#include "libavutil/opt.h"
#include "avformat.h"
#include "avi.h"
#include "dv.h"
@ -59,6 +60,7 @@ typedef struct AVIStream {
} AVIStream;
typedef struct {
const AVClass *class;
int64_t riff_end;
int64_t movi_end;
int64_t fsize;
@ -70,9 +72,24 @@ typedef struct {
int stream_index;
DVDemuxContext* dv_demux;
int odml_depth;
int use_odml;
#define MAX_ODML_DEPTH 1000
} AVIContext;
static const AVOption options[] = {
{ "use_odml", "use odml index", offsetof(AVIContext, use_odml), FF_OPT_TYPE_INT, 1, -1, 1, AV_OPT_FLAG_DECODING_PARAM},
{ NULL },
};
static const AVClass demuxer_class = {
"AVI demuxer",
av_default_item_name,
options,
LIBAVUTIL_VERSION_INT,
};
static const char avi_headers[][8] = {
{ 'R', 'I', 'F', 'F', 'A', 'V', 'I', ' ' },
{ 'R', 'I', 'F', 'F', 'A', 'V', 'I', 'X' },
@ -354,6 +371,8 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (get_riff(s, pb) < 0)
return -1;
av_log(avi, AV_LOG_DEBUG, "use odml:%d\n", avi->use_odml);
avi->fsize = avio_size(pb);
if(avi->fsize<=0)
avi->fsize= avi->riff_end == 8 ? INT64_MAX : avi->riff_end;
@ -673,7 +692,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
break;
case MKTAG('i', 'n', 'd', 'x'):
i= avio_tell(pb);
if(pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX)){
if(pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) && avi->use_odml){
read_braindead_odml_indx(s, 0);
}
avio_seek(pb, i+size, SEEK_SET);
@ -1385,4 +1404,5 @@ AVInputFormat ff_avi_demuxer = {
avi_read_packet,
avi_read_close,
avi_read_seek,
.priv_class = &demuxer_class,
};