History

Merge remote-tracking branch 'qatar/master'

* qatar/master: build: remove empty $(OBJS) target build: make rule for linking ff* apply only to these targets build: rearrange some lines in a more logical way s302m: fix resampling for 16 and 24bits. ARM: remove MUL64 and MAC64 inline asm build: clean up .PHONY lists build: move all (un)install* target aliases to toplevel Makefile flvenc: propagate error properly build: remove stale dependency build: do not add CFLAGS-yes to CFLAGS utils.c: fix crash with threading enabled. configure: simplify source_path setup configure: remove --source-path option lavf: deprecate AVFormatParameters.time_base. img2: add framerate private option. img2: add video_size private option. img2: add pixel_format private option. tty: add framerate private option. Conflicts: Makefile configure

Michael Niedermayer committed 15 years ago

Commit 174df6a2 parents 3a1aaf7 b9c6c7c9 files · +86 −76Browse files

Showing the changes to libavformat (4 of 9 files). Show all

Unified · Split

4 files
  1. libavformat/avformat.h +1 −1
  2. libavformat/flvenc.c +1 −1
  3. libavformat/img2.c +59 −11
  4. libavformat/tty.c +10 −6
libavformat/avformat.h+1−1
@@ -227,8 +227,8 @@ typedef struct AVProbeData { · 226 unmodified lines
227227 #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer
228228
229229 typedef struct AVFormatParameters {
230− AVRational time_base;
231230 #if FF_API_FORMAT_PARAMETERS
231+ attribute_deprecated AVRational time_base;
232232 attribute_deprecated int sample_rate;
233233 attribute_deprecated int channels;
234234 attribute_deprecated int width;
libavformat/flvenc.c+1−1
@@ -440,7 +440,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) · 439 unmodified lines
440440
441441 av_free(data);
442442
443− return 0;
443+ return pb->error;
444444 }
445445
446446 AVOutputFormat ff_flv_muxer = {
libavformat/img2.c+59−11
@@ -22,12 +22,17 @@ · 21 unmodified lines
2222
2323 #include "libavutil/intreadwrite.h"
2424 #include "libavutil/avstring.h"
25+#include "libavutil/log.h"
26+#include "libavutil/opt.h"
27+#include "libavutil/pixdesc.h"
28+#include "libavutil/parseutils.h"
2529 #include "avformat.h"
2630 #include "avio_internal.h"
2731 #include "internal.h"
2832 #include <strings.h>
2933
3034 typedef struct {
35+ const AVClass *class; /**< Class for private options. */
3136 int img_first;
3237 int img_last;
3338 int img_number;
@@ -35,6 +40,9 @@ typedef struct { · 1 unmodified line
3540 int is_pipe;
3641 int split_planes; /**< use independent file for each Y, U, V plane */
3742 char path[1024];
43+ char *pixel_format; /**< Set by a private option. */
44+ char *video_size; /**< Set by a private option. */
45+ char *framerate; /**< Set by a private option. */
3846 } VideoData;
3947
4048 typedef struct {
@@ -202,8 +210,11 @@ enum CodecID av_guess_image2_codec(const char *filename){ · 161 unmodified lines
202210 static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
203211 {
204212 VideoData *s = s1->priv_data;
205− int first_index, last_index;
213+ int first_index, last_index, ret = 0;
214+ int width = 0, height = 0;
206215 AVStream *st;
216+ enum PixelFormat pix_fmt = PIX_FMT_NONE;
217+ AVRational framerate;
207218
208219 s1->ctx_flags |= AVFMTCTX_NOHEADER;
209220
@@ -212,6 +223,29 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap) · 2 unmodified lines
212223 return AVERROR(ENOMEM);
213224 }
214225
226+ if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) {
227+ av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format);
228+ return AVERROR(EINVAL);
229+ }
230+ if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) {
231+ av_log(s, AV_LOG_ERROR, "Could not parse video size: %s.\n", s->video_size);
232+ return ret;
233+ }
234+ if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) {
235+ av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate);
236+ return ret;
237+ }
238+#if FF_API_FORMAT_PARAMETERS
239+ if (ap->pix_fmt != PIX_FMT_NONE)
240+ pix_fmt = ap->pix_fmt;
241+ if (ap->width > 0)
242+ width = ap->width;
243+ if (ap->height > 0)
244+ height = ap->height;
245+ if (ap->time_base.num)
246+ framerate = (AVRational){ap->time_base.den, ap->time_base.num};
247+#endif
248+
215249 av_strlcpy(s->path, s1->filename, sizeof(s->path));
216250 s->img_number = 0;
217251 s->img_count = 0;
@@ -224,15 +258,11 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap) · 6 unmodified lines
224258 st->need_parsing = AVSTREAM_PARSE_FULL;
225259 }
226260
227− if (!ap->time_base.num) {
228− av_set_pts_info(st, 60, 1, 25);
229− } else {
230− av_set_pts_info(st, 60, ap->time_base.num, ap->time_base.den);
231− }
261+ av_set_pts_info(st, 60, framerate.den, framerate.num);
232262
233− if(ap->width && ap->height){
234− st->codec->width = ap->width;
235− st->codec->height= ap->height;
263+ if (width && height) {
264+ st->codec->width = width;
265+ st->codec->height = height;
236266 }
237267
238268 if (!s->is_pipe) {
@@ -258,8 +288,8 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap) · 19 unmodified lines
258288 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
259289 st->codec->codec_id = av_str2id(img_tags, s->path);
260290 }
261− if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NONE)
262− st->codec->pix_fmt = ap->pix_fmt;
291+ if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != PIX_FMT_NONE)
292+ st->codec->pix_fmt = pix_fmt;
263293
264294 return 0;
265295 }
@@ -430,6 +460,22 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) · 164 unmodified lines
430460
431461 #endif /* CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER */
432462
463+#define OFFSET(x) offsetof(VideoData, x)
464+#define DEC AV_OPT_FLAG_DECODING_PARAM
465+static const AVOption options[] = {
466+ { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
467+ { "video_size", "", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
468+ { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
469+ { NULL },
470+};
471+
472+static const AVClass img2_class = {
473+ .class_name = "image2 demuxer",
474+ .item_name = av_default_item_name,
475+ .option = options,
476+ .version = LIBAVUTIL_VERSION_INT,
477+};
478+
433479 /* input */
434480 #if CONFIG_IMAGE2_DEMUXER
435481 AVInputFormat ff_image2_demuxer = {
@@ -440,6 +486,7 @@ AVInputFormat ff_image2_demuxer = { · 4 unmodified lines
440486 .read_header = read_header,
441487 .read_packet = read_packet,
442488 .flags = AVFMT_NOFILE,
489+ .priv_class = &img2_class,
443490 };
444491 #endif
445492 #if CONFIG_IMAGE2PIPE_DEMUXER
@@ -449,6 +496,7 @@ AVInputFormat ff_image2pipe_demuxer = { · 3 unmodified lines
449496 .priv_data_size = sizeof(VideoData),
450497 .read_header = read_header,
451498 .read_packet = read_packet,
499+ .priv_class = &img2_class,
452500 };
453501 #endif
454502
libavformat/tty.c+10−6
@@ -37,6 +37,7 @@ typedef struct { · 36 unmodified lines
3737 int chars_per_frame;
3838 uint64_t fsize; /**< file size less metadata buffer */
3939 char *video_size;/**< A string describing video size, set by a private option. */
40+ char *framerate; /**< Set by a private option. */
4041 } TtyDemuxContext;
4142
4243 /**
@@ -75,6 +76,7 @@ static int read_header(AVFormatContext *avctx, · 32 unmodified lines
7576 TtyDemuxContext *s = avctx->priv_data;
7677 int width = 0, height = 0, ret = 0;
7778 AVStream *st = av_new_stream(avctx, 0);
79+ AVRational framerate;
7880
7981 if (!st) {
8082 ret = AVERROR(ENOMEM);
@@ -88,20 +90,21 @@ static int read_header(AVFormatContext *avctx, · 7 unmodified lines
8890 av_log (avctx, AV_LOG_ERROR, "Couldn't parse video size.\n");
8991 goto fail;
9092 }
93+ if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) {
94+ av_log(avctx, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate);
95+ goto fail;
96+ }
9197 #if FF_API_FORMAT_PARAMETERS
9298 if (ap->width > 0)
9399 width = ap->width;
94100 if (ap->height > 0)
95101 height = ap->height;
102+ if (ap->time_base.num)
103+ framerate = (AVRational){ap->time_base.den, ap->time_base.num};
96104 #endif
97105 st->codec->width = width;
98106 st->codec->height = height;
99−
100− if (!ap->time_base.num) {
101− av_set_pts_info(st, 60, 1, 25);
102− } else {
103− av_set_pts_info(st, 60, ap->time_base.num, ap->time_base.den);
104− }
107+ av_set_pts_info(st, 60, framerate.den, framerate.num);
105108
106109 /* simulate tty display speed */
107110 #if FF_API_FORMAT_PARAMETERS
@@ -152,6 +155,7 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt) · 44 unmodified lines
152155 static const AVOption options[] = {
153156 { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), FF_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM},
154157 { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
158+ { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
155159 { NULL },
156160 };
157161

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t