#include "avformat.h"
#include "internal.h"
-typedef struct {
+typedef struct VideoDemuxData {
const AVClass *class; /**< Class for private options. */
int img_first;
int img_last;
avpriv_set_pts_info(st, 60, framerate.den, framerate.num);
if (width && height) {
- st->codec->width = width;
- st->codec->height = height;
+ st->codecpar->width = width;
+ st->codecpar->height = height;
}
if (!s->is_pipe) {
return AVERROR(ENOENT);
s->img_first = first_index;
s->img_last = last_index;
- s->img_number = first_index;
+ s->img_number = s->start_number != 1 ? s->start_number : first_index;
/* compute duration */
st->start_time = 0;
st->duration = last_index - first_index + 1;
}
if (s1->video_codec_id) {
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = s1->video_codec_id;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = s1->video_codec_id;
} else if (s1->audio_codec_id) {
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = s1->audio_codec_id;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = s1->audio_codec_id;
} else {
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = ff_guess_image2_codec(s->path);
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = ff_guess_image2_codec(s->path);
}
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
pix_fmt != AV_PIX_FMT_NONE)
- st->codec->pix_fmt = pix_fmt;
+ st->codecpar->format = pix_fmt;
return 0;
}
int i, res;
int size[3] = { 0 }, ret[3] = { 0 };
AVIOContext *f[3] = { NULL };
- AVCodecContext *codec = s1->streams[0]->codec;
+ AVCodecParameters *par = s1->streams[0]->codecpar;
if (!s->is_pipe) {
/* loop over input */
s->img_number) < 0 && s->img_number > 1)
return AVERROR(EIO);
for (i = 0; i < 3; i++) {
- if (avio_open2(&f[i], filename, AVIO_FLAG_READ,
- &s1->interrupt_callback, NULL) < 0) {
+ if (s1->io_open(s1, &f[i], filename, AVIO_FLAG_READ, NULL) < 0) {
if (i >= 1)
break;
av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",
}
size[i] = avio_size(f[i]);
- if (codec->codec_id != AV_CODEC_ID_RAWVIDEO)
+ if (par->codec_id != AV_CODEC_ID_RAWVIDEO)
break;
filename[strlen(filename) - 1] = 'U' + i;
}
- if (codec->codec_id == AV_CODEC_ID_RAWVIDEO && !codec->width)
- infer_size(&codec->width, &codec->height, size[0]);
+ if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->width)
+ infer_size(&par->width, &par->height, size[0]);
} else {
f[0] = s1->pb;
if (f[0]->eof_reached)
if (f[i]) {
ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]);
if (!s->is_pipe)
- avio_close(f[i]);
+ ff_format_io_close(s1, &f[i]);
if (ret[i] > 0)
pkt->size += ret[i];
}
}
if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(EIO); /* signal EOF */
} else {
s->img_count++;