[FFmpeg-devel] [PATCH 5/5] img2dec: make use of AV_OPT_TYPE_IMAGE_SIZE
Stefano Sabatini
stefasab at gmail.com
Fri Apr 5 17:24:16 CEST 2013
On date Friday 2013-04-05 15:09:28 +0000, Paul B Mahol encoded:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> libavformat/img2dec.c | 19 ++++++-------------
> 1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
> index 2929d2e..dc7ac1e 100644
> --- a/libavformat/img2dec.c
> +++ b/libavformat/img2dec.c
> @@ -52,7 +52,7 @@ typedef struct {
> int split_planes; /**< use independent file for each Y, U, V plane */
> char path[1024];
> char *pixel_format; /**< Set by a private option. */
> - char *video_size; /**< Set by a private option. */
> + int width, height; /**< Set by a private option. */
> AVRational framerate; /**< Set by a private option. */
> int loop;
> enum { PT_GLOB_SEQUENCE, PT_GLOB, PT_SEQUENCE } pattern_type;
> @@ -193,8 +193,7 @@ static int img_read_probe(AVProbeData *p)
> static int img_read_header(AVFormatContext *s1)
> {
> VideoDemuxData *s = s1->priv_data;
> - int first_index, last_index, ret = 0;
> - int width = 0, height = 0;
> + int first_index, last_index;
> AVStream *st;
> enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
>
> @@ -211,12 +210,6 @@ static int img_read_header(AVFormatContext *s1)
> s->pixel_format);
> return AVERROR(EINVAL);
> }
> - if (s->video_size &&
> - (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) {
> - av_log(s, AV_LOG_ERROR,
> - "Could not parse video size: %s.\n", s->video_size);
> - return ret;
> - }
>
> av_strlcpy(s->path, s1->filename, sizeof(s->path));
> s->img_number = 0;
> @@ -232,9 +225,9 @@ static int img_read_header(AVFormatContext *s1)
>
> avpriv_set_pts_info(st, 60, s->framerate.den, s->framerate.num);
>
> - if (width && height) {
> - st->codec->width = width;
> - st->codec->height = height;
> + if (s->width && s->height) {
> + st->codec->width = s->width;
> + st->codec->height = s->height;
> }
>
> if (!s->is_pipe) {
> @@ -449,7 +442,7 @@ static const AVOption options[] = {
> { "pixel_format", "set video pixel format", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
> { "start_number", "set first number in the sequence", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, DEC },
> { "start_number_range", "set range for looking at the first sequence number", OFFSET(start_number_range), AV_OPT_TYPE_INT, {.i64 = 5}, 1, INT_MAX, DEC },
> - { "video_size", "set video size", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
> + { "video_size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, DEC },
> { "frame_size", "force frame size in bytes", OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, DEC },
> { NULL },
> };
LGTM.
--
FFmpeg = Faithful and Fancy Magical Practical Ecletic Geisha
More information about the ffmpeg-devel
mailing list