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