X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Ftty.c;h=f4535bbd1c464b873437305505ec307db57bede5;hb=8ca39b855a7b0e4d9f726fa9d285bc8edcb953e6;hp=ecd3f58c77996a3f3b09d4588036a453dbd90063;hpb=c1dcbfddf9d8c484121824f876a1d8faee26d7fa;p=ffmpeg diff --git a/libavformat/tty.c b/libavformat/tty.c index ecd3f58c779..f4535bbd1c4 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -27,12 +27,14 @@ #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" #include "libavutil/log.h" +#include "libavutil/dict.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "avformat.h" +#include "internal.h" #include "sauce.h" -typedef struct { +typedef struct TtyDemuxContext { AVClass *class; int chars_per_frame; uint64_t fsize; /**< file size less metadata buffer */ @@ -60,7 +62,7 @@ static int efi_read(AVFormatContext *avctx, uint64_t start_pos) return -1; \ if (avio_read(pb, buf, size) == size) { \ buf[len] = 0; \ - av_metadata_set2(&avctx->metadata, name, buf, 0); \ + av_dict_set(&avctx->metadata, name, buf, 0); \ } GET_EFI_META("filename", 12) @@ -70,21 +72,20 @@ static int efi_read(AVFormatContext *avctx, uint64_t start_pos) return 0; } -static int read_header(AVFormatContext *avctx, - AVFormatParameters *ap) +static int read_header(AVFormatContext *avctx) { TtyDemuxContext *s = avctx->priv_data; int width = 0, height = 0, ret = 0; - AVStream *st = av_new_stream(avctx, 0); + AVStream *st = avformat_new_stream(avctx, NULL); AVRational framerate; if (!st) { ret = AVERROR(ENOMEM); goto fail; } - st->codec->codec_tag = 0; - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = CODEC_ID_ANSI; + st->codecpar->codec_tag = 0; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id = AV_CODEC_ID_ANSI; if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) { av_log (avctx, AV_LOG_ERROR, "Couldn't parse video size.\n"); @@ -94,26 +95,15 @@ static int read_header(AVFormatContext *avctx, av_log(avctx, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate); goto fail; } -#if FF_API_FORMAT_PARAMETERS - if (ap->width > 0) - width = ap->width; - if (ap->height > 0) - height = ap->height; - if (ap->time_base.num) - framerate = (AVRational){ap->time_base.den, ap->time_base.num}; -#endif - st->codec->width = width; - st->codec->height = height; - av_set_pts_info(st, 60, framerate.den, framerate.num); + st->codecpar->width = width; + st->codecpar->height = height; + avpriv_set_pts_info(st, 60, framerate.den, framerate.num); + st->avg_frame_rate = framerate; /* simulate tty display speed */ -#if FF_API_FORMAT_PARAMETERS - if (ap->sample_rate) - s->chars_per_frame = ap->sample_rate; -#endif s->chars_per_frame = FFMAX(av_q2d(st->time_base)*s->chars_per_frame, 1); - if (avctx->pb->seekable) { + if (avctx->pb->seekable & AVIO_SEEKABLE_NORMAL) { s->fsize = avio_size(avctx->pb); st->duration = (s->fsize + s->chars_per_frame - 1) / s->chars_per_frame; @@ -153,9 +143,9 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt) #define OFFSET(x) offsetof(TtyDemuxContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), FF_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM}, - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), AV_OPT_TYPE_INT, {.i64 = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM}, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, { NULL }, };