Browse code

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

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/06/07 10:37:57
Showing 9 changed files
... ...
@@ -80,12 +80,15 @@ endef
80 80
 
81 81
 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
82 82
 
83
+ffplay.o: CFLAGS += $(SDL_CFLAGS)
83 84
 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
84 85
 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
85 86
 
86
-%_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
87
+$(PROGS): %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
87 88
 	$(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
88 89
 
90
+alltools: $(TOOLS)
91
+
89 92
 tools/%$(EXESUF): tools/%.o
90 93
 	$(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
91 94
 
... ...
@@ -95,8 +98,6 @@ tools/%.o: tools/%.c
95 95
 -include $(wildcard tools/*.d)
96 96
 -include $(wildcard tests/*.d)
97 97
 
98
-ffplay.o: CFLAGS += $(SDL_CFLAGS)
99
-
100 98
 VERSION_SH  = $(SRC_PATH_BARE)/version.sh
101 99
 GIT_LOG     = $(SRC_PATH_BARE)/.git/logs/HEAD
102 100
 
... ...
@@ -110,8 +111,6 @@ version.h .version:
110 110
 # force version.sh to run whenever version might have changed
111 111
 -include .version
112 112
 
113
-alltools: $(TOOLS)
114
-
115 113
 DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES)
116 114
 
117 115
 documentation: $(DOCS)
... ...
@@ -134,7 +133,9 @@ doc/%.1: TAG = MAN
134 134
 doc/%.1: doc/%.pod
135 135
 	$(M)pod2man --section=1 --center=" " --release=" " $< > $@
136 136
 
137
-install: $(INSTALL_TARGETS-yes)
137
+install: install-libs install-headers $(INSTALL_TARGETS-yes)
138
+
139
+install-libs: install-libs-yes
138 140
 
139 141
 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
140 142
 	$(Q)mkdir -p "$(BINDIR)"
... ...
@@ -148,7 +149,7 @@ install-man: $(MANPAGES)
148 148
 	$(Q)mkdir -p "$(MANDIR)/man1"
149 149
 	$(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
150 150
 
151
-uninstall: uninstall-progs uninstall-data uninstall-man
151
+uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data uninstall-man
152 152
 
153 153
 uninstall-progs:
154 154
 	$(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
... ...
@@ -293,4 +294,5 @@ $(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
293 293
 fate-list:
294 294
 	@printf '%s\n' $(sort $(FATE))
295 295
 
296
-.PHONY: documentation *test regtest-* alltools check config
296
+.PHONY: all alltools *clean check config documentation examples install*
297
+.PHONY: *test testprogs uninstall*
... ...
@@ -45,8 +45,6 @@ HOSTCFLAGS += $(IFLAGS)
45 45
 %.ho: %.h
46 46
 	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
47 47
 
48
-%$(EXESUF): %.c
49
-
50 48
 %.ver: %.v
51 49
 	$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
52 50
 
... ...
@@ -56,24 +54,14 @@ HOSTCFLAGS += $(IFLAGS)
56 56
 %.h:
57 57
 	@:
58 58
 
59
-install: install-libs install-headers
60
-install-libs: install-libs-yes
61
-
62
-uninstall: uninstall-libs uninstall-headers
63
-
64
-.PHONY: all depend dep *clean install* uninstall* examples testprogs
65
-
66 59
 # Disable suffix rules.  Most of the builtin rules are suffix rules,
67 60
 # so this saves some time on slow systems.
68 61
 .SUFFIXES:
69 62
 
70
-# Do not delete intermediate files from chains of implicit rules
71
-$(OBJS):
72 63
 endif
73 64
 
74 65
 OBJS-$(HAVE_MMX) +=  $(MMX-OBJS-yes)
75 66
 
76
-CFLAGS    += $(CFLAGS-yes)
77 67
 OBJS      += $(OBJS-yes)
78 68
 FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
79 69
 TESTPROGS += $(TESTPROGS-yes)
... ...
@@ -192,7 +192,6 @@ External library support:
192 192
   --enable-zlib            enable zlib [autodetect]
193 193
 
194 194
 Advanced options (experts only):
195
-  --source-path=PATH       path to source code [$source_path]
196 195
   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
197 196
   --enable-cross-compile   assume a cross-compiler is used
198 197
   --sysroot=PATH           root of cross-build tree
... ...
@@ -1190,7 +1189,6 @@ CMDLINE_SET="
1190 1190
     nm
1191 1191
     pkg_config
1192 1192
     samples
1193
-    source_path
1194 1193
     strip
1195 1194
     sysinclude
1196 1195
     sysroot
... ...
@@ -1715,13 +1713,12 @@ DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)
1715 1715
 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
1716 1716
 
1717 1717
 # find source path
1718
-source_path="$(dirname "$0")"
1719
-enable source_path_used
1720 1718
 if test -f configure; then
1721 1719
     source_path="$(pwd)"
1722 1720
     disable source_path_used
1723 1721
 else
1724
-    source_path="$(cd "$source_path"; pwd)"
1722
+    source_path=$(cd $(dirname "$0"); pwd)
1723
+    enable source_path_used
1725 1724
     echo "$source_path" | grep -q '[[:blank:]]' &&
1726 1725
         die "Out of tree builds are impossible with whitespace in source path."
1727 1726
     test -e "$source_path/config.h" &&
... ...
@@ -28,45 +28,16 @@
28 28
 
29 29
 #if HAVE_INLINE_ASM
30 30
 
31
-#define MULH MULH
32
-#define MUL64 MUL64
33
-
34 31
 #if HAVE_ARMV6
32
+#define MULH MULH
35 33
 static inline av_const int MULH(int a, int b)
36 34
 {
37 35
     int r;
38 36
     __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
39 37
     return r;
40 38
 }
41
-
42
-static inline av_const int64_t MUL64(int a, int b)
43
-{
44
-    int64_t x;
45
-    __asm__ ("smull %Q0, %R0, %1, %2" : "=r"(x) : "r"(a), "r"(b));
46
-    return x;
47
-}
48
-#else
49
-static inline av_const int MULH(int a, int b)
50
-{
51
-    int lo, hi;
52
-    __asm__ ("smull %0, %1, %2, %3" : "=&r"(lo), "=&r"(hi) : "r"(b), "r"(a));
53
-    return hi;
54
-}
55
-
56
-static inline av_const int64_t MUL64(int a, int b)
57
-{
58
-    int64_t x;
59
-    __asm__ ("smull %Q0, %R0, %1, %2" : "=&r"(x) : "r"(a), "r"(b));
60
-    return x;
61
-}
62 39
 #endif
63 40
 
64
-static inline av_const int64_t MAC64(int64_t d, int a, int b)
65
-{
66
-    __asm__ ("smlal %Q0, %R0, %1, %2" : "+r"(d) : "r"(a), "r"(b));
67
-    return d;
68
-}
69
-#define MAC64(d, a, b) ((d) = MAC64(d, a, b))
70 41
 #define MLS64(d, a, b) MAC64(d, -(a), b)
71 42
 
72 43
 #if HAVE_ARMV5TE
... ...
@@ -107,7 +107,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
107 107
             *o++ = (av_reverse[buf[6] & 0xf0] << 28) |
108 108
                    (av_reverse[buf[5]]        << 20) |
109 109
                    (av_reverse[buf[4]]        << 12) |
110
-                   (av_reverse[buf[3] & 0x0f] <<  8);
110
+                   (av_reverse[buf[3] & 0x0f] <<  4);
111 111
             buf += 7;
112 112
         }
113 113
         *data_size = (uint8_t*) o - (uint8_t*) data;
... ...
@@ -130,7 +130,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
130 130
                     av_reverse[buf[0]];
131 131
             *o++ = (av_reverse[buf[4] & 0xf0] << 12) |
132 132
                    (av_reverse[buf[3]]        <<  4) |
133
-                    av_reverse[buf[2] & 0x0f];
133
+                   (av_reverse[buf[2]]        >>  4);
134 134
             buf += 5;
135 135
         }
136 136
         *data_size = (uint8_t*) o - (uint8_t*) data;
... ...
@@ -227,8 +227,8 @@ typedef struct AVProbeData {
227 227
 #define AVPROBE_PADDING_SIZE 32             ///< extra allocated bytes at the end of the probe buffer
228 228
 
229 229
 typedef struct AVFormatParameters {
230
-    AVRational time_base;
231 230
 #if FF_API_FORMAT_PARAMETERS
231
+    attribute_deprecated AVRational time_base;
232 232
     attribute_deprecated int sample_rate;
233 233
     attribute_deprecated int channels;
234 234
     attribute_deprecated int width;
... ...
@@ -440,7 +440,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
440 440
 
441 441
     av_free(data);
442 442
 
443
-    return 0;
443
+    return pb->error;
444 444
 }
445 445
 
446 446
 AVOutputFormat ff_flv_muxer = {
... ...
@@ -22,12 +22,17 @@
22 22
 
23 23
 #include "libavutil/intreadwrite.h"
24 24
 #include "libavutil/avstring.h"
25
+#include "libavutil/log.h"
26
+#include "libavutil/opt.h"
27
+#include "libavutil/pixdesc.h"
28
+#include "libavutil/parseutils.h"
25 29
 #include "avformat.h"
26 30
 #include "avio_internal.h"
27 31
 #include "internal.h"
28 32
 #include <strings.h>
29 33
 
30 34
 typedef struct {
35
+    const AVClass *class;  /**< Class for private options. */
31 36
     int img_first;
32 37
     int img_last;
33 38
     int img_number;
... ...
@@ -35,6 +40,9 @@ typedef struct {
35 35
     int is_pipe;
36 36
     int split_planes;  /**< use independent file for each Y, U, V plane */
37 37
     char path[1024];
38
+    char *pixel_format;     /**< Set by a private option. */
39
+    char *video_size;       /**< Set by a private option. */
40
+    char *framerate;        /**< Set by a private option. */
38 41
 } VideoData;
39 42
 
40 43
 typedef struct {
... ...
@@ -202,8 +210,11 @@ enum CodecID av_guess_image2_codec(const char *filename){
202 202
 static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
203 203
 {
204 204
     VideoData *s = s1->priv_data;
205
-    int first_index, last_index;
205
+    int first_index, last_index, ret = 0;
206
+    int width = 0, height = 0;
206 207
     AVStream *st;
208
+    enum PixelFormat pix_fmt = PIX_FMT_NONE;
209
+    AVRational framerate;
207 210
 
208 211
     s1->ctx_flags |= AVFMTCTX_NOHEADER;
209 212
 
... ...
@@ -212,6 +223,29 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
212 212
         return AVERROR(ENOMEM);
213 213
     }
214 214
 
215
+    if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) {
216
+        av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format);
217
+        return AVERROR(EINVAL);
218
+    }
219
+    if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) {
220
+        av_log(s, AV_LOG_ERROR, "Could not parse video size: %s.\n", s->video_size);
221
+        return ret;
222
+    }
223
+    if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) {
224
+        av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate);
225
+        return ret;
226
+    }
227
+#if FF_API_FORMAT_PARAMETERS
228
+    if (ap->pix_fmt != PIX_FMT_NONE)
229
+        pix_fmt = ap->pix_fmt;
230
+    if (ap->width > 0)
231
+        width = ap->width;
232
+    if (ap->height > 0)
233
+        height = ap->height;
234
+    if (ap->time_base.num)
235
+        framerate = (AVRational){ap->time_base.den, ap->time_base.num};
236
+#endif
237
+
215 238
     av_strlcpy(s->path, s1->filename, sizeof(s->path));
216 239
     s->img_number = 0;
217 240
     s->img_count = 0;
... ...
@@ -224,15 +258,11 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
224 224
         st->need_parsing = AVSTREAM_PARSE_FULL;
225 225
     }
226 226
 
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
-    }
227
+    av_set_pts_info(st, 60, framerate.den, framerate.num);
232 228
 
233
-    if(ap->width && ap->height){
234
-        st->codec->width = ap->width;
235
-        st->codec->height= ap->height;
229
+    if (width && height) {
230
+        st->codec->width  = width;
231
+        st->codec->height = height;
236 232
     }
237 233
 
238 234
     if (!s->is_pipe) {
... ...
@@ -258,8 +288,8 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
258 258
         st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
259 259
         st->codec->codec_id = av_str2id(img_tags, s->path);
260 260
     }
261
-    if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NONE)
262
-        st->codec->pix_fmt = ap->pix_fmt;
261
+    if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != PIX_FMT_NONE)
262
+        st->codec->pix_fmt = pix_fmt;
263 263
 
264 264
     return 0;
265 265
 }
... ...
@@ -430,6 +460,22 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
430 430
 
431 431
 #endif /* CONFIG_IMAGE2_MUXER || CONFIG_IMAGE2PIPE_MUXER */
432 432
 
433
+#define OFFSET(x) offsetof(VideoData, x)
434
+#define DEC AV_OPT_FLAG_DECODING_PARAM
435
+static const AVOption options[] = {
436
+    { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
437
+    { "video_size",   "", OFFSET(video_size),   FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
438
+    { "framerate",    "", OFFSET(framerate),    FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
439
+    { NULL },
440
+};
441
+
442
+static const AVClass img2_class = {
443
+    .class_name = "image2 demuxer",
444
+    .item_name  = av_default_item_name,
445
+    .option     = options,
446
+    .version    = LIBAVUTIL_VERSION_INT,
447
+};
448
+
433 449
 /* input */
434 450
 #if CONFIG_IMAGE2_DEMUXER
435 451
 AVInputFormat ff_image2_demuxer = {
... ...
@@ -440,6 +486,7 @@ AVInputFormat ff_image2_demuxer = {
440 440
     .read_header    = read_header,
441 441
     .read_packet    = read_packet,
442 442
     .flags          = AVFMT_NOFILE,
443
+    .priv_class     = &img2_class,
443 444
 };
444 445
 #endif
445 446
 #if CONFIG_IMAGE2PIPE_DEMUXER
... ...
@@ -449,6 +496,7 @@ AVInputFormat ff_image2pipe_demuxer = {
449 449
     .priv_data_size = sizeof(VideoData),
450 450
     .read_header    = read_header,
451 451
     .read_packet    = read_packet,
452
+    .priv_class     = &img2_class,
452 453
 };
453 454
 #endif
454 455
 
... ...
@@ -37,6 +37,7 @@ typedef struct {
37 37
     int chars_per_frame;
38 38
     uint64_t fsize;  /**< file size less metadata buffer */
39 39
     char *video_size;/**< A string describing video size, set by a private option. */
40
+    char *framerate; /**< Set by a private option. */
40 41
 } TtyDemuxContext;
41 42
 
42 43
 /**
... ...
@@ -75,6 +76,7 @@ static int read_header(AVFormatContext *avctx,
75 75
     TtyDemuxContext *s = avctx->priv_data;
76 76
     int width = 0, height = 0, ret = 0;
77 77
     AVStream *st = av_new_stream(avctx, 0);
78
+    AVRational framerate;
78 79
 
79 80
     if (!st) {
80 81
         ret = AVERROR(ENOMEM);
... ...
@@ -88,20 +90,21 @@ static int read_header(AVFormatContext *avctx,
88 88
         av_log (avctx, AV_LOG_ERROR, "Couldn't parse video size.\n");
89 89
         goto fail;
90 90
     }
91
+    if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) {
92
+        av_log(avctx, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate);
93
+        goto fail;
94
+    }
91 95
 #if FF_API_FORMAT_PARAMETERS
92 96
     if (ap->width > 0)
93 97
         width = ap->width;
94 98
     if (ap->height > 0)
95 99
         height = ap->height;
100
+    if (ap->time_base.num)
101
+        framerate = (AVRational){ap->time_base.den, ap->time_base.num};
96 102
 #endif
97 103
     st->codec->width  = width;
98 104
     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
-    }
105
+    av_set_pts_info(st, 60, framerate.den, framerate.num);
105 106
 
106 107
     /* simulate tty display speed */
107 108
 #if FF_API_FORMAT_PARAMETERS
... ...
@@ -152,6 +155,7 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
152 152
 static const AVOption options[] = {
153 153
     { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), FF_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM},
154 154
     { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
155
+    { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
155 156
     { NULL },
156 157
 };
157 158