Commit 3c5fe5b5 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master: (22 commits)
  wma: Clip WMA1 and WMA2 frame length to 11 bits.
  movenc: Don't require frame_size to be set for modes other than mov
  doc: Update APIchanges with info on muxer flushing
  movenc: Reindent a block
  tools: Remove some unnecessary #undefs.
  rv20: prevent calling ff_h263_decode_mba() with unset height/width
  tools: K&R reformatting cosmetics
  Ignore generated aviocat and ismindex tools.
  build: Automatically include architecture-specific library Makefile snippets.
  indeo5: prevent null pointer dereference on broken files
  pktdumper: Use usleep instead of sleep
  cosmetics: Remove some unnecessary block braces.
  Drop unnecessary prefix from *sink* variable and struct names.
  Add a tool for creating smooth streaming manifests
  movdec: Calculate an average bit rate for fragmented streams, too
  movenc: Write the sample rate instead of time scale in the stsd atom
  movenc: Add a separate ismv/isma (smooth streaming) muxer
  movenc: Allow the caller to decide on fragmentation
  libavformat: Add a flag for muxers that support write_packet(NULL) for flushing
  movenc: Add support for writing fragmented mov files
  ...

Conflicts:
	Changelog
	cmdutils.c
	cmdutils.h
	doc/APIchanges
	ffmpeg.c
	ffplay.c
	libavfilter/Makefile
	libavformat/Makefile
	libavformat/avformat.h
	libavformat/movenc.c
	libavformat/movenc.h
	libavformat/version.h
	tools/graph2dot.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 01e5e970 d78bb1a4
...@@ -44,8 +44,10 @@ tests/tiny_psnr ...@@ -44,8 +44,10 @@ tests/tiny_psnr
tests/videogen tests/videogen
tests/vsynth1 tests/vsynth1
tests/vsynth2 tests/vsynth2
tools/aviocat
tools/cws2fws tools/cws2fws
tools/graph2dot tools/graph2dot
tools/ismindex
tools/lavfi-showfiltfmts tools/lavfi-showfiltfmts
tools/pktdumper tools/pktdumper
tools/probetest tools/probetest
......
...@@ -12,6 +12,7 @@ version next: ...@@ -12,6 +12,7 @@ version next:
- tinterlace video filter - tinterlace video filter
- astreamsync audio filter - astreamsync audio filter
- amerge audio filter - amerge audio filter
- ISMV (Smooth Streaming) muxer
- GSM audio parser - GSM audio parser
- SMJPEG muxer - SMJPEG muxer
- XWD encoder and decoder - XWD encoder and decoder
......
...@@ -77,6 +77,7 @@ define DOSUBDIR ...@@ -77,6 +77,7 @@ define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V)))) $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/ SUBDIR := $(1)/
include $(SRC_PATH)/$(1)/Makefile include $(SRC_PATH)/$(1)/Makefile
-include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
include $(SRC_PATH)/library.mak include $(SRC_PATH)/library.mak
endef endef
......
...@@ -16,6 +16,12 @@ API changes, most recent first: ...@@ -16,6 +16,12 @@ API changes, most recent first:
2012-01-24 - xxxxxxx - lavfi 2.60.100 2012-01-24 - xxxxxxx - lavfi 2.60.100
Add avfilter_graph_dump. Add avfilter_graph_dump.
2012-01-25 - lavf 53.22.0
f1caf01 Allow doing av_write_frame(ctx, NULL) for flushing possible
buffered data within a muxer. Added AVFMT_ALLOW_FLUSH for
muxers supporting it (av_write_frame makes sure it is called
only for muxers with this flag).
2012-01-15 - lavc 53.34.0 2012-01-15 - lavc 53.34.0
New audio encoding API: New audio encoding API:
b2c75b6 Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio b2c75b6 Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio
......
...@@ -629,6 +629,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) ...@@ -629,6 +629,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
"src", args, NULL, ost->graph); "src", args, NULL, ost->graph);
if (ret < 0) if (ret < 0)
return ret; return ret;
#if FF_API_OLD_VSINK_API #if FF_API_OLD_VSINK_API
ret = avfilter_graph_create_filter(&ost->output_video_filter, avfilter_get_by_name("buffersink"), ret = avfilter_graph_create_filter(&ost->output_video_filter, avfilter_get_by_name("buffersink"),
"out", NULL, pix_fmts, ost->graph); "out", NULL, pix_fmts, ost->graph);
...@@ -638,6 +639,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) ...@@ -638,6 +639,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
"out", NULL, buffersink_params, ost->graph); "out", NULL, buffersink_params, ost->graph);
#endif #endif
av_freep(&buffersink_params); av_freep(&buffersink_params);
if (ret < 0) if (ret < 0)
return ret; return ret;
last_filter = ost->input_video_filter; last_filter = ost->input_video_filter;
......
...@@ -1745,6 +1745,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c ...@@ -1745,6 +1745,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src", if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src",
NULL, is, graph)) < 0) NULL, is, graph)) < 0)
return ret; return ret;
#if FF_API_OLD_VSINK_API #if FF_API_OLD_VSINK_API
ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "out", ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "out",
NULL, pix_fmts, graph); NULL, pix_fmts, graph);
......
...@@ -721,8 +721,6 @@ OBJS-$(CONFIG_MLIB) += mlib/dsputil_mlib.o \ ...@@ -721,8 +721,6 @@ OBJS-$(CONFIG_MLIB) += mlib/dsputil_mlib.o \
# well. # well.
OBJS-$(!CONFIG_SMALL) += inverse.o OBJS-$(!CONFIG_SMALL) += inverse.o
-include $(SRC_PATH)/$(SUBDIR)$(ARCH)/Makefile
SKIPHEADERS += %_tablegen.h \ SKIPHEADERS += %_tablegen.h \
%_tables.h \ %_tables.h \
aac_tablegen_decl.h \ aac_tablegen_decl.h \
......
...@@ -454,6 +454,10 @@ static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band, ...@@ -454,6 +454,10 @@ static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band,
ref_mb = tile->ref_mbs; ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos; offs = tile->ypos * band->pitch + tile->xpos;
if (!ref_mb &&
((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
return AVERROR_INVALIDDATA;
/* scale factor for motion vectors */ /* scale factor for motion vectors */
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3); mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0; mv_x = mv_y = 0;
......
...@@ -1301,28 +1301,26 @@ static int ff_estimate_motion_b(MpegEncContext * s, ...@@ -1301,28 +1301,26 @@ static int ff_estimate_motion_b(MpegEncContext * s,
break; break;
case ME_X1: case ME_X1:
case ME_EPZS: case ME_EPZS:
{ P_LEFT[0] = mv_table[mot_xy - 1][0];
P_LEFT[0] = mv_table[mot_xy - 1][0]; P_LEFT[1] = mv_table[mot_xy - 1][1];
P_LEFT[1] = mv_table[mot_xy - 1][1];
if(P_LEFT[0] > (c->xmax<<shift)) P_LEFT[0] = (c->xmax<<shift);
/* special case for first line */ if (P_LEFT[0] > (c->xmax << shift)) P_LEFT[0] = (c->xmax << shift);
if (!s->first_slice_line) {
P_TOP[0] = mv_table[mot_xy - mot_stride ][0];
P_TOP[1] = mv_table[mot_xy - mot_stride ][1];
P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1 ][0];
P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1 ][1];
if(P_TOP[1] > (c->ymax<<shift)) P_TOP[1]= (c->ymax<<shift);
if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); /* special case for first line */
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); if (!s->first_slice_line) {
} P_TOP[0] = mv_table[mot_xy - mot_stride ][0];
c->pred_x= P_LEFT[0]; P_TOP[1] = mv_table[mot_xy - mot_stride ][1];
c->pred_y= P_LEFT[1]; P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1][0];
P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1][1];
if (P_TOP[1] > (c->ymax << shift)) P_TOP[1] = (c->ymax << shift);
if (P_TOPRIGHT[0] < (c->xmin << shift)) P_TOPRIGHT[0] = (c->xmin << shift);
if (P_TOPRIGHT[1] > (c->ymax << shift)) P_TOPRIGHT[1] = (c->ymax << shift);
P_MEDIAN[0] = mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
} }
c->pred_x = P_LEFT[0];
c->pred_y = P_LEFT[1];
if(mv_table == s->b_forw_mv_table){ if(mv_table == s->b_forw_mv_table){
mv_scale= (s->pb_time<<16) / (s->pp_time<<shift); mv_scale= (s->pb_time<<16) / (s->pp_time<<shift);
......
...@@ -379,7 +379,8 @@ static int rv20_decode_picture_header(MpegEncContext *s) ...@@ -379,7 +379,8 @@ static int rv20_decode_picture_header(MpegEncContext *s)
if(s->avctx->debug & FF_DEBUG_PICT_INFO){ if(s->avctx->debug & FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits); av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits);
} }
} } else if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0)
return AVERROR_INVALIDDATA;
mb_pos = ff_h263_decode_mba(s); mb_pos = ff_h263_decode_mba(s);
......
...@@ -85,7 +85,7 @@ int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version, ...@@ -85,7 +85,7 @@ int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version,
} else if (sample_rate <= 22050 || } else if (sample_rate <= 22050 ||
(sample_rate <= 32000 && version == 1)) { (sample_rate <= 32000 && version == 1)) {
frame_len_bits = 10; frame_len_bits = 10;
} else if (sample_rate <= 48000) { } else if (sample_rate <= 48000 || version < 3) {
frame_len_bits = 11; frame_len_bits = 11;
} else if (sample_rate <= 96000) { } else if (sample_rate <= 96000) {
frame_len_bits = 12; frame_len_bits = 12;
......
...@@ -839,7 +839,7 @@ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w, ...@@ -839,7 +839,7 @@ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w,
} }
if (sides&EDGE_BOTTOM) { if (sides&EDGE_BOTTOM) {
for(i = 0; i < w; i += 4) { for(i = 0; i < h; i += 4) {
ptr= last_line + (i + 1) * wrap - w; ptr= last_line + (i + 1) * wrap - w;
__asm__ volatile( __asm__ volatile(
"1: \n\t" "1: \n\t"
......
...@@ -106,7 +106,6 @@ OBJS-$(CONFIG_TESTSRC_FILTER) += vsrc_testsrc.o ...@@ -106,7 +106,6 @@ OBJS-$(CONFIG_TESTSRC_FILTER) += vsrc_testsrc.o
OBJS-$(CONFIG_BUFFERSINK_FILTER) += sink_buffer.o OBJS-$(CONFIG_BUFFERSINK_FILTER) += sink_buffer.o
OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o
OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/mp_image.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/mp_image.o
OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/img_format.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/img_format.o
OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_2xsai.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_2xsai.o
...@@ -164,8 +163,6 @@ OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_yvu9.o ...@@ -164,8 +163,6 @@ OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_yvu9.o
OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/pullup.o OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/pullup.o
-include $(SRC_PATH)/$(SUBDIR)$(ARCH)/Makefile
DIRS = x86 libmpcodecs DIRS = x86 libmpcodecs
TESTPROGS = formats TESTPROGS = formats
......
...@@ -96,10 +96,8 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) ...@@ -96,10 +96,8 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
for (i = 0; i < h>>vsub; i++) { for (i = 0; i < h>>vsub; i++) {
switch (step) { switch (step) {
case 1: case 1:
{
for (j = 0; j < (inlink->w >> hsub); j++) for (j = 0; j < (inlink->w >> hsub); j++)
outrow[j] = inrow[-j]; outrow[j] = inrow[-j];
}
break; break;
case 2: case 2:
......
...@@ -374,4 +374,4 @@ OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o ...@@ -374,4 +374,4 @@ OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o
SKIPHEADERS-$(CONFIG_NETWORK) += network.h rtsp.h SKIPHEADERS-$(CONFIG_NETWORK) += network.h rtsp.h
TESTPROGS = seek TESTPROGS = seek
TOOLS = aviocat pktdumper probetest TOOLS = aviocat ismindex pktdumper probetest
...@@ -119,6 +119,7 @@ void av_register_all(void) ...@@ -119,6 +119,7 @@ void av_register_all(void)
REGISTER_DEMUXER (INGENIENT, ingenient); REGISTER_DEMUXER (INGENIENT, ingenient);
REGISTER_DEMUXER (IPMOVIE, ipmovie); REGISTER_DEMUXER (IPMOVIE, ipmovie);
REGISTER_MUXER (IPOD, ipod); REGISTER_MUXER (IPOD, ipod);
REGISTER_MUXER (ISMV, ismv);
REGISTER_DEMUXER (ISS, iss); REGISTER_DEMUXER (ISS, iss);
REGISTER_DEMUXER (IV8, iv8); REGISTER_DEMUXER (IV8, iv8);
REGISTER_MUXDEMUX (IVF, ivf); REGISTER_MUXDEMUX (IVF, ivf);
......
...@@ -380,6 +380,7 @@ typedef struct AVFormatParameters { ...@@ -380,6 +380,7 @@ typedef struct AVFormatParameters {
#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */ #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */
#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */ #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */
#define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */
#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */
#define AVFMT_TS_NONSTRICT 0x8000000 /**< Format does not require strictly #define AVFMT_TS_NONSTRICT 0x8000000 /**< Format does not require strictly
increasing timestamps, but they must increasing timestamps, but they must
still be monotonic */ still be monotonic */
...@@ -406,12 +407,19 @@ typedef struct AVOutputFormat { ...@@ -406,12 +407,19 @@ typedef struct AVOutputFormat {
enum CodecID audio_codec; /**< default audio codec */ enum CodecID audio_codec; /**< default audio codec */
enum CodecID video_codec; /**< default video codec */ enum CodecID video_codec; /**< default video codec */
int (*write_header)(struct AVFormatContext *); int (*write_header)(struct AVFormatContext *);
/**
* Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
* pkt can be NULL in order to flush data buffered in the muxer.
* When flushing, return 0 if there still is more data to flush,
* or 1 if everything was flushed and there is no more buffered
* data.
*/
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
int (*write_trailer)(struct AVFormatContext *); int (*write_trailer)(struct AVFormatContext *);
/** /**
* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE,
* AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
* AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH
*/ */
int flags; int flags;
...@@ -1803,8 +1811,12 @@ attribute_deprecated int av_write_header(AVFormatContext *s); ...@@ -1803,8 +1811,12 @@ attribute_deprecated int av_write_header(AVFormatContext *s);
* *
* @param s media file handle * @param s media file handle
* @param pkt The packet, which contains the stream_index, buf/buf_size, * @param pkt The packet, which contains the stream_index, buf/buf_size,
dts/pts, ... * dts/pts, ...
* @return < 0 on error, = 0 if OK, 1 if end of stream wanted * This can be NULL (at any time, not just at the end), in
* order to immediately flush data buffered within the muxer,
* for muxers that buffer up data internally before writing it
* to the output.
* @return < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush
*/ */
int av_write_frame(AVFormatContext *s, AVPacket *pkt); int av_write_frame(AVFormatContext *s, AVPacket *pkt);
......
...@@ -127,6 +127,7 @@ typedef struct MOVStreamContext { ...@@ -127,6 +127,7 @@ typedef struct MOVStreamContext {
int dts_shift; ///< dts shift when ctts is negative int dts_shift; ///< dts shift when ctts is negative
uint32_t palette[256]; uint32_t palette[256];
int has_palette; int has_palette;
int64_t data_size;
} MOVStreamContext; } MOVStreamContext;
typedef struct MOVContext { typedef struct MOVContext {
......
...@@ -1643,8 +1643,10 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -1643,8 +1643,10 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
init_get_bits(&gb, buf, 8*num_bytes); init_get_bits(&gb, buf, 8*num_bytes);
for (i=0; i<entries; i++) for (i = 0; i < entries; i++) {
sc->sample_sizes[i] = get_bits_long(&gb, field_size); sc->sample_sizes[i] = get_bits_long(&gb, field_size);
sc->data_size += sc->sample_sizes[i];
}
av_free(buf); av_free(buf);
return 0; return 0;
...@@ -2347,6 +2349,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -2347,6 +2349,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
distance++; distance++;
dts += sample_duration; dts += sample_duration;
offset += sample_size; offset += sample_size;
sc->data_size += sample_size;
} }
frag->moof_offset = offset; frag->moof_offset = offset;
st->duration = dts + sc->time_offset; st->duration = dts + sc->time_offset;
...@@ -2722,6 +2725,16 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -2722,6 +2725,16 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
mov_read_timecode_track(s, s->streams[i]); mov_read_timecode_track(s, s->streams[i]);
} }
if (mov->trex_data) {
int i;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
if (st->duration)
st->codec->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
}
}
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
// ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4 // ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4
#define MODE_3G2 0x10 #define MODE_3G2 0x10
#define MODE_IPOD 0x20 #define MODE_IPOD 0x20
#define MODE_ISM 0x40
typedef struct MOVIentry { typedef struct MOVIentry {
uint64_t pos; uint64_t pos;
...@@ -50,7 +51,6 @@ typedef struct MOVIentry { ...@@ -50,7 +51,6 @@ typedef struct MOVIentry {
#define MOV_SYNC_SAMPLE 0x0001 #define MOV_SYNC_SAMPLE 0x0001
#define MOV_PARTIAL_SYNC_SAMPLE 0x0002 #define MOV_PARTIAL_SYNC_SAMPLE 0x0002
uint32_t flags; uint32_t flags;
uint8_t *data;
} MOVIentry; } MOVIentry;
typedef struct HintSample { typedef struct HintSample {
...@@ -67,6 +67,13 @@ typedef struct { ...@@ -67,6 +67,13 @@ typedef struct {
HintSample *samples; HintSample *samples;
} HintSampleQueue; } HintSampleQueue;
typedef struct {
int64_t offset;
int64_t time;
int64_t duration;
int64_t tfrf_offset;
} MOVFragmentInfo;
typedef struct MOVIndex { typedef struct MOVIndex {
int mode; int mode;
int entry; int entry;
...@@ -87,14 +94,12 @@ typedef struct MOVIndex { ...@@ -87,14 +94,12 @@ typedef struct MOVIndex {
int vosLen; int vosLen;
uint8_t *vosData; uint8_t *vosData;
int cluster_write_index;
MOVIentry *cluster; MOVIentry *cluster;
int audio_vbr; int audio_vbr;
int height; ///< active picture (w/o VBI) height for D-10/IMX int height; ///< active picture (w/o VBI) height for D-10/IMX
uint32_t tref_tag; uint32_t tref_tag;
int tref_id; ///< trackID of the referenced track int tref_id; ///< trackID of the referenced track
uint32_t trex_flags; int64_t start_dts;
int trex_size;
int hint_track; ///< the track that hints this track, -1 if no hint track is set int hint_track; ///< the track that hints this track, -1 if no hint track is set
int src_track; ///< the track that this hint track describes int src_track; ///< the track that this hint track describes
...@@ -102,9 +107,21 @@ typedef struct MOVIndex { ...@@ -102,9 +107,21 @@ typedef struct MOVIndex {
uint32_t prev_rtp_ts; uint32_t prev_rtp_ts;
int64_t cur_rtp_ts_unwrapped; int64_t cur_rtp_ts_unwrapped;
uint32_t max_packet_size; uint32_t max_packet_size;
int64_t base_data_offset_pos;
int64_t default_duration;
uint32_t default_sample_flags;
uint32_t default_size;
HintSampleQueue sample_queue; HintSampleQueue sample_queue;
AVIOContext *mdat_buf;
int64_t moof_size_offset;
int64_t data_offset;
int64_t frag_start;
int64_t tfrf_offset;
int nb_frag_info;
MOVFragmentInfo *frag_info;
} MOVTrack; } MOVTrack;
typedef struct MOVMuxContext { typedef struct MOVMuxContext {
...@@ -116,22 +133,28 @@ typedef struct MOVMuxContext { ...@@ -116,22 +133,28 @@ typedef struct MOVMuxContext {
int64_t mdat_pos; int64_t mdat_pos;
uint64_t mdat_size; uint64_t mdat_size;
MOVTrack *tracks; MOVTrack *tracks;
int fragments;
int frag_seq_num;
int flags; int flags;
int rtp_flags; int rtp_flags;
int reserved_moov_size; int reserved_moov_size;
int64_t reserved_moov_pos; int64_t reserved_moov_pos;
int max_fragment_duration;
int max_fragment_size;
int iods_skip; int iods_skip;
int iods_video_profile; int iods_video_profile;
int iods_audio_profile; int iods_audio_profile;
int fragments;
int max_fragment_duration;
int max_fragment_size;
int ism_lookahead;
} MOVMuxContext; } MOVMuxContext;
#define FF_MOV_FLAG_RTP_HINT 1 #define FF_MOV_FLAG_RTP_HINT 1
#define FF_MOV_FLAG_FRAGMENT 2
#define FF_MOV_FLAG_EMPTY_MOOV 4
#define FF_MOV_FLAG_FRAG_KEYFRAME 8
#define FF_MOV_FLAG_SEPARATE_MOOF 16
#define FF_MOV_FLAG_FRAG_CUSTOM 32
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
......
...@@ -3336,7 +3336,15 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){ ...@@ -3336,7 +3336,15 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){
int av_write_frame(AVFormatContext *s, AVPacket *pkt) int av_write_frame(AVFormatContext *s, AVPacket *pkt)
{ {
int ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt); int ret;
if (!pkt) {
if (s->oformat->flags & AVFMT_ALLOW_FLUSH)
return s->oformat->write_packet(s, pkt);
return 1;
}
ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt);
if(ret<0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) if(ret<0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
return ret; return ret;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53 #define LIBAVFORMAT_VERSION_MAJOR 53
#define LIBAVFORMAT_VERSION_MINOR 30 #define LIBAVFORMAT_VERSION_MINOR 31
#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
......
...@@ -99,7 +99,6 @@ yuv2planeX_altivec(const int16_t *filter, int filterSize, ...@@ -99,7 +99,6 @@ yuv2planeX_altivec(const int16_t *filter, int filterSize,
const uint8_t *dither, int offset) const uint8_t *dither, int offset)
{ {
register int i, j; register int i, j;
{
DECLARE_ALIGNED(16, int, val)[dstW]; DECLARE_ALIGNED(16, int, val)[dstW];
for (i=0; i<dstW; i++) for (i=0; i<dstW; i++)
...@@ -142,7 +141,6 @@ yuv2planeX_altivec(const int16_t *filter, int filterSize, ...@@ -142,7 +141,6 @@ yuv2planeX_altivec(const int16_t *filter, int filterSize,
} }
} }
altivec_packIntArrayToCharArray(val, dest, dstW); altivec_packIntArrayToCharArray(val, dest, dstW);
}
} }
static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
...@@ -166,7 +164,6 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, ...@@ -166,7 +164,6 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
else else
switch (filterSize) { switch (filterSize) {
case 4: case 4:
{
for (i=0; i<dstW; i++) { for (i=0; i<dstW; i++) {
register int srcPos = filterPos[i]; register int srcPos = filterPos[i];
...@@ -201,11 +198,9 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, ...@@ -201,11 +198,9 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
vec_st(val_s, 0, tempo); vec_st(val_s, 0, tempo);
dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1); dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
} }
}
break; break;
case 8: case 8:
{
for (i=0; i<dstW; i++) { for (i=0; i<dstW; i++) {
register int srcPos = filterPos[i]; register int srcPos = filterPos[i];
...@@ -228,11 +223,9 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, ...@@ -228,11 +223,9 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
vec_st(val_s, 0, tempo); vec_st(val_s, 0, tempo);
dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1); dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
} }
}
break; break;
case 16: case 16:
{
for (i=0; i<dstW; i++) { for (i=0; i<dstW; i++) {
register int srcPos = filterPos[i]; register int srcPos = filterPos[i];
...@@ -257,11 +250,9 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, ...@@ -257,11 +250,9 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
vec_st(val_s, 0, tempo); vec_st(val_s, 0, tempo);
dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1); dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
} }
}
break; break;
default: default:
{
for (i=0; i<dstW; i++) { for (i=0; i<dstW; i++) {
register int j; register int j;
register int srcPos = filterPos[i]; register int srcPos = filterPos[i];
...@@ -321,7 +312,6 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, ...@@ -321,7 +312,6 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
} }
} }
}
} }
void ff_sws_init_swScale_altivec(SwsContext *c) void ff_sws_init_swScale_altivec(SwsContext *c)
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "libavformat/avformat.h" #include "libavformat/avformat.h"
static int usage(const char *argv0, int ret) static int usage(const char *argv0, int ret)
...@@ -80,13 +81,14 @@ int main(int argc, char **argv) ...@@ -80,13 +81,14 @@ int main(int argc, char **argv)
stream_pos += n; stream_pos += n;
if (bps) { if (bps) {
avio_flush(output); avio_flush(output);
while ((av_gettime() - start_time)*bps/AV_TIME_BASE < stream_pos) while ((av_gettime() - start_time) * bps / AV_TIME_BASE < stream_pos)
usleep(50*1000); usleep(50 * 1000);
} }
} }
avio_flush(output); avio_flush(output);
avio_close(output); avio_close(output);
fail: fail:
avio_close(input); avio_close(input);
avformat_network_deinit(); avformat_network_deinit();
......
...@@ -26,46 +26,42 @@ int main(int argc, char *argv[]) ...@@ -26,46 +26,42 @@ int main(int argc, char *argv[])
z_stream zstream; z_stream zstream;
struct stat statbuf; struct stat statbuf;
if (argc < 3) if (argc < 3) {
{
printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]); printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]);
return 1; return 1;
} }
fd_in = open(argv[1], O_RDONLY); fd_in = open(argv[1], O_RDONLY);
if (fd_in < 0) if (fd_in < 0) {
{
perror("Error opening input file"); perror("Error opening input file");
return 1; return 1;
} }
fd_out = open(argv[2], O_WRONLY|O_CREAT, 00644); fd_out = open(argv[2], O_WRONLY | O_CREAT, 00644);
if (fd_out < 0) if (fd_out < 0) {
{
perror("Error opening output file"); perror("Error opening output file");
close(fd_in); close(fd_in);
return 1; return 1;
} }
if (read(fd_in, &buf_in, 8) != 8) if (read(fd_in, &buf_in, 8) != 8) {
{
printf("Header error\n"); printf("Header error\n");
close(fd_in); close(fd_in);
close(fd_out); close(fd_out);
return 1; return 1;
} }
if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') {
{
printf("Not a compressed flash file\n"); printf("Not a compressed flash file\n");
return 1; return 1;
} }
fstat(fd_in, &statbuf); fstat(fd_in, &statbuf);
comp_len = statbuf.st_size; comp_len = statbuf.st_size;
uncomp_len = buf_in[4] | (buf_in[5] << 8) | (buf_in[6] << 16) | (buf_in[7] << 24); uncomp_len = buf_in[4] | (buf_in[5] << 8) | (buf_in[6] << 16) | (buf_in[7] << 24);
printf("Compressed size: %d Uncompressed size: %d\n", comp_len-4, uncomp_len-4); printf("Compressed size: %d Uncompressed size: %d\n",
comp_len - 4, uncomp_len - 4);
// write out modified header // write out modified header
buf_in[0] = 'F'; buf_in[0] = 'F';
...@@ -75,36 +71,35 @@ int main(int argc, char *argv[]) ...@@ -75,36 +71,35 @@ int main(int argc, char *argv[])
} }
zstream.zalloc = NULL; zstream.zalloc = NULL;
zstream.zfree = NULL; zstream.zfree = NULL;
zstream.opaque = NULL; zstream.opaque = NULL;
inflateInit(&zstream); inflateInit(&zstream);
for (i = 0; i < comp_len-8;) for (i = 0; i < comp_len - 8;) {
{
int ret, len = read(fd_in, &buf_in, 1024); int ret, len = read(fd_in, &buf_in, 1024);
dbgprintf("read %d bytes\n", len); dbgprintf("read %d bytes\n", len);
last_out = zstream.total_out; last_out = zstream.total_out;
zstream.next_in = &buf_in[0]; zstream.next_in = &buf_in[0];
zstream.avail_in = len; zstream.avail_in = len;
zstream.next_out = &buf_out[0]; zstream.next_out = &buf_out[0];
zstream.avail_out = 65536; zstream.avail_out = 65536;
ret = inflate(&zstream, Z_SYNC_FLUSH); ret = inflate(&zstream, Z_SYNC_FLUSH);
if (ret != Z_STREAM_END && ret != Z_OK) if (ret != Z_STREAM_END && ret != Z_OK) {
{
printf("Error while decompressing: %d\n", ret); printf("Error while decompressing: %d\n", ret);
inflateEnd(&zstream); inflateEnd(&zstream);
return 1; return 1;
} }
dbgprintf("a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out\n", dbgprintf("a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out\n",
zstream.avail_in, zstream.total_in, zstream.avail_out, zstream.total_out, zstream.avail_in, zstream.total_in, zstream.avail_out,
zstream.total_out-last_out); zstream.total_out, zstream.total_out - last_out);
if (write(fd_out, &buf_out, zstream.total_out - last_out) < zstream.total_out - last_out) { if (write(fd_out, &buf_out, zstream.total_out - last_out) <
zstream.total_out - last_out) {
perror("Error writing output file"); perror("Error writing output file");
return 1; return 1;
} }
...@@ -115,15 +110,14 @@ int main(int argc, char *argv[]) ...@@ -115,15 +110,14 @@ int main(int argc, char *argv[])
break; break;
} }
if (zstream.total_out != uncomp_len-8) if (zstream.total_out != uncomp_len - 8) {
{
printf("Size mismatch (%lu != %d), updating header...\n", printf("Size mismatch (%lu != %d), updating header...\n",
zstream.total_out, uncomp_len-8); zstream.total_out, uncomp_len - 8);
buf_in[0] = (zstream.total_out+8) & 0xff; buf_in[0] = (zstream.total_out + 8) & 0xff;
buf_in[1] = ((zstream.total_out+8) >> 8) & 0xff; buf_in[1] = ((zstream.total_out + 8) >> 8) & 0xff;
buf_in[2] = ((zstream.total_out+8) >> 16) & 0xff; buf_in[2] = ((zstream.total_out + 8) >> 16) & 0xff;
buf_in[3] = ((zstream.total_out+8) >> 24) & 0xff; buf_in[3] = ((zstream.total_out + 8) >> 24) & 0xff;
lseek(fd_out, 4, SEEK_SET); lseek(fd_out, 4, SEEK_SET);
if (write(fd_out, &buf_in, 4) < 4) { if (write(fd_out, &buf_in, 4) < 4) {
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <unistd.h> /* getopt */ #include <unistd.h> /* getopt */
#undef HAVE_AV_CONFIG_H
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "libavutil/audioconvert.h" #include "libavutil/audioconvert.h"
#include "libavfilter/avfiltergraph.h" #include "libavfilter/avfiltergraph.h"
...@@ -63,19 +62,25 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph) ...@@ -63,19 +62,25 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph)
char dst_filter_ctx_label[128]; char dst_filter_ctx_label[128];
const AVFilterContext *dst_filter_ctx = link->dst; const AVFilterContext *dst_filter_ctx = link->dst;
snprintf(dst_filter_ctx_label, sizeof(dst_filter_ctx_label), "%s (%s)", snprintf(dst_filter_ctx_label, sizeof(dst_filter_ctx_label),
"%s (%s)",
dst_filter_ctx->name, dst_filter_ctx->name,
dst_filter_ctx->filter->name); dst_filter_ctx->filter->name);
fprintf(outfile, "\"%s\" -> \"%s\"", filter_ctx_label, dst_filter_ctx_label); fprintf(outfile, "\"%s\" -> \"%s\"",
filter_ctx_label, dst_filter_ctx_label);
if (link->type == AVMEDIA_TYPE_VIDEO) { if (link->type == AVMEDIA_TYPE_VIDEO) {
fprintf(outfile, " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]", fprintf(outfile,
" [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]",
av_pix_fmt_descriptors[link->format].name, av_pix_fmt_descriptors[link->format].name,
link->w, link->h, link->time_base.num, link->time_base.den); link->w, link->h, link->time_base.num,
link->time_base.den);
} else if (link->type == AVMEDIA_TYPE_AUDIO) { } else if (link->type == AVMEDIA_TYPE_AUDIO) {
char buf[255]; char buf[255];
av_get_channel_layout_string(buf, sizeof(buf), -1, link->channel_layout); av_get_channel_layout_string(buf, sizeof(buf), -1,
fprintf(outfile, " [ label= \"fmt:%s sr:%"PRId64" cl:%s tb:%d/%d\" ]", link->channel_layout);
fprintf(outfile,
" [ label= \"fmt:%s sr:%"PRId64" cl:%s tb:%d/%d\" ]",
av_get_sample_fmt_name(link->format), av_get_sample_fmt_name(link->format),
link->sample_rate, buf, link->sample_rate, buf,
link->time_base.num, link->time_base.den); link->time_base.num, link->time_base.den);
...@@ -90,17 +95,17 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph) ...@@ -90,17 +95,17 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const char *outfilename = NULL; const char *outfilename = NULL;
const char *infilename = NULL; const char *infilename = NULL;
FILE *outfile = NULL; FILE *outfile = NULL;
FILE *infile = NULL; FILE *infile = NULL;
char *graph_string = NULL; char *graph_string = NULL;
AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph)); AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph));
char c; char c;
av_log_set_level(AV_LOG_DEBUG); av_log_set_level(AV_LOG_DEBUG);
while ((c = getopt(argc, argv, "hi:o:")) != -1) { while ((c = getopt(argc, argv, "hi:o:")) != -1) {
switch(c) { switch (c) {
case 'h': case 'h':
usage(); usage();
return 0; return 0;
...@@ -119,7 +124,8 @@ int main(int argc, char **argv) ...@@ -119,7 +124,8 @@ int main(int argc, char **argv)
infilename = "/dev/stdin"; infilename = "/dev/stdin";
infile = fopen(infilename, "r"); infile = fopen(infilename, "r");
if (!infile) { if (!infile) {
fprintf(stderr, "Impossible to open input file '%s': %s\n", infilename, strerror(errno)); fprintf(stderr, "Impossible to open input file '%s': %s\n",
infilename, strerror(errno));
return 1; return 1;
} }
...@@ -127,7 +133,8 @@ int main(int argc, char **argv) ...@@ -127,7 +133,8 @@ int main(int argc, char **argv)
outfilename = "/dev/stdout"; outfilename = "/dev/stdout";
outfile = fopen(outfilename, "w"); outfile = fopen(outfilename, "w");
if (!outfile) { if (!outfile) {
fprintf(stderr, "Impossible to open output file '%s': %s\n", outfilename, strerror(errno)); fprintf(stderr, "Impossible to open output file '%s': %s\n",
outfilename, strerror(errno));
return 1; return 1;
} }
...@@ -142,7 +149,7 @@ int main(int argc, char **argv) ...@@ -142,7 +149,7 @@ int main(int argc, char **argv)
struct line *new_line = av_malloc(sizeof(struct line)); struct line *new_line = av_malloc(sizeof(struct line));
count += strlen(last_line->data); count += strlen(last_line->data);
last_line->next = new_line; last_line->next = new_line;
last_line = new_line; last_line = new_line;
} }
last_line->next = NULL; last_line->next = NULL;
......
This diff is collapsed.
...@@ -97,11 +97,13 @@ int main(int argc, char **argv) ...@@ -97,11 +97,13 @@ int main(int argc, char **argv)
} }
if (avfilter_open(&filter_ctx, filter, NULL) < 0) { if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
fprintf(stderr, "Inpossible to open filter with name '%s'\n", filter_name); fprintf(stderr, "Inpossible to open filter with name '%s'\n",
filter_name);
return 1; return 1;
} }
if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) { if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n", filter_name, filter_args); fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
filter_name, filter_args);
return 1; return 1;
} }
......
...@@ -24,11 +24,10 @@ ...@@ -24,11 +24,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "libavformat/avformat.h"
#define PKTFILESUFF "_%08"PRId64"_%02d_%010"PRId64"_%06d_%c.bin" #include "libavformat/avformat.h"
#undef strcat #define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin"
static int usage(int ret) static int usage(int ret)
{ {
...@@ -46,10 +45,10 @@ int main(int argc, char **argv) ...@@ -46,10 +45,10 @@ int main(int argc, char **argv)
char pktfilename[PATH_MAX]; char pktfilename[PATH_MAX];
AVFormatContext *fctx = NULL; AVFormatContext *fctx = NULL;
AVPacket pkt; AVPacket pkt;
int64_t pktnum = 0; int64_t pktnum = 0;
int64_t maxpkts = 0; int64_t maxpkts = 0;
int donotquit = 0; int donotquit = 0;
int nowrite = 0; int nowrite = 0;
int err; int err;
if ((argc > 1) && !strncmp(argv[1], "-", 1)) { if ((argc > 1) && !strncmp(argv[1], "-", 1)) {
...@@ -64,16 +63,16 @@ int main(int argc, char **argv) ...@@ -64,16 +63,16 @@ int main(int argc, char **argv)
return usage(1); return usage(1);
if (argc > 2) if (argc > 2)
maxpkts = atoi(argv[2]); maxpkts = atoi(argv[2]);
strncpy(fntemplate, argv[1], PATH_MAX-1); strncpy(fntemplate, argv[1], PATH_MAX - 1);
if (strrchr(argv[1], '/')) if (strrchr(argv[1], '/'))
strncpy(fntemplate, strrchr(argv[1], '/')+1, PATH_MAX-1); strncpy(fntemplate, strrchr(argv[1], '/') + 1, PATH_MAX - 1);
if (strrchr(fntemplate, '.')) if (strrchr(fntemplate, '.'))
*strrchr(fntemplate, '.') = '\0'; *strrchr(fntemplate, '.') = '\0';
if (strchr(fntemplate, '%')) { if (strchr(fntemplate, '%')) {
fprintf(stderr, "can't use filenames containing '%%'\n"); fprintf(stderr, "can't use filenames containing '%%'\n");
return usage(1); return usage(1);
} }
if (strlen(fntemplate) + sizeof(PKTFILESUFF) >= PATH_MAX-1) { if (strlen(fntemplate) + sizeof(PKTFILESUFF) >= PATH_MAX - 1) {
fprintf(stderr, "filename too long\n"); fprintf(stderr, "filename too long\n");
return usage(1); return usage(1);
} }
...@@ -99,11 +98,14 @@ int main(int argc, char **argv) ...@@ -99,11 +98,14 @@ int main(int argc, char **argv)
while ((err = av_read_frame(fctx, &pkt)) >= 0) { while ((err = av_read_frame(fctx, &pkt)) >= 0) {
int fd; int fd;
snprintf(pktfilename, PATH_MAX-1, fntemplate, pktnum, pkt.stream_index, pkt.pts, pkt.size, (pkt.flags & AV_PKT_FLAG_KEY)?'K':'_'); snprintf(pktfilename, PATH_MAX - 1, fntemplate, pktnum,
printf(PKTFILESUFF"\n", pktnum, pkt.stream_index, pkt.pts, pkt.size, (pkt.flags & AV_PKT_FLAG_KEY)?'K':'_'); pkt.stream_index, pkt.pts, pkt.size,
(pkt.flags & AV_PKT_FLAG_KEY) ? 'K' : '_');
printf(PKTFILESUFF "\n", pktnum, pkt.stream_index, pkt.pts, pkt.size,
(pkt.flags & AV_PKT_FLAG_KEY) ? 'K' : '_');
//printf("open(\"%s\")\n", pktfilename); //printf("open(\"%s\")\n", pktfilename);
if (!nowrite) { if (!nowrite) {
fd = open(pktfilename, O_WRONLY|O_CREAT, 0644); fd = open(pktfilename, O_WRONLY | O_CREAT, 0644);
err = write(fd, pkt.data, pkt.size); err = write(fd, pkt.data, pkt.size);
if (err < 0) { if (err < 0) {
fprintf(stderr, "write: error %d\n", err); fprintf(stderr, "write: error %d\n", err);
...@@ -120,7 +122,7 @@ int main(int argc, char **argv) ...@@ -120,7 +122,7 @@ int main(int argc, char **argv)
avformat_close_input(&fctx); avformat_close_input(&fctx);
while (donotquit) while (donotquit)
sleep(60); usleep(60 * 1000000);
return 0; return 0;
} }
...@@ -39,7 +39,8 @@ static void probe(AVProbeData *pd, int type, int p, int size) ...@@ -39,7 +39,8 @@ static void probe(AVProbeData *pd, int type, int p, int size)
int score = fmt->read_probe(pd); int score = fmt->read_probe(pd);
if (score > score_array[i] && score > AVPROBE_SCORE_MAX / 4) { if (score > score_array[i] && score > AVPROBE_SCORE_MAX / 4) {
score_array[i] = score; score_array[i] = score;
fprintf(stderr, "Failure of %s probing code with score=%d type=%d p=%X size=%d\n", fprintf(stderr,
"Failure of %s probing code with score=%d type=%d p=%X size=%d\n",
fmt->name, score, type, p, size); fmt->name, score, type, p, size);
failures++; failures++;
} }
...@@ -75,9 +76,8 @@ int main(void) ...@@ -75,9 +76,8 @@ int main(void)
init_put_bits(&pb, pd.buf, size); init_put_bits(&pb, pd.buf, size);
switch (type) { switch (type) {
case 0: case 0:
for (i = 0; i < size * 8; i++) { for (i = 0; i < size * 8; i++)
put_bits(&pb, 1, (av_lfg_get(&state) & 0xFFFFFFFF) > p << 20); put_bits(&pb, 1, (av_lfg_get(&state) & 0xFFFFFFFF) > p << 20);
}
break; break;
case 1: case 1:
for (i = 0; i < size * 8; i++) { for (i = 0; i < size * 8; i++) {
...@@ -89,10 +89,10 @@ int main(void) ...@@ -89,10 +89,10 @@ int main(void)
break; break;
case 2: case 2:
for (i = 0; i < size * 8; i++) { for (i = 0; i < size * 8; i++) {
unsigned int p2 = (p >> (hist*3)) & 7; unsigned int p2 = (p >> (hist * 3)) & 7;
unsigned int v = (av_lfg_get(&state) & 0xFFFFFFFF) > p2 << 29; unsigned int v = (av_lfg_get(&state) & 0xFFFFFFFF) > p2 << 29;
put_bits(&pb, 1, v); put_bits(&pb, 1, v);
hist = (2*hist + v) & 3; hist = (2 * hist + v) & 3;
} }
break; break;
case 3: case 3:
...@@ -100,12 +100,18 @@ int main(void) ...@@ -100,12 +100,18 @@ int main(void)
int c = 0; int c = 0;
while (p & 63) { while (p & 63) {
c = (av_lfg_get(&state) & 0xFFFFFFFF) >> 24; c = (av_lfg_get(&state) & 0xFFFFFFFF) >> 24;
if (c >= 'a' && c <= 'z' && (p & 1)) break; if (c >= 'a' && c <= 'z' && (p & 1))
else if(c >= 'A' && c <= 'Z' && (p & 2)) break; break;
else if(c >= '0' && c <= '9' && (p & 4)) break; else if (c >= 'A' && c <= 'Z' && (p & 2))
else if(c == ' ' && (p & 8)) break; break;
else if(c == 0 && (p & 16)) break; else if (c >= '0' && c <= '9' && (p & 4))
else if(c == 1 && (p & 32)) break; break;
else if (c == ' ' && (p & 8))
break;
else if (c == 0 && (p & 16))
break;
else if (c == 1 && (p & 32))
break;
} }
pd.buf[i] = c; pd.buf[i] = c;
} }
......
...@@ -138,7 +138,6 @@ int main(int argc, char *argv[]) ...@@ -138,7 +138,6 @@ int main(int argc, char *argv[])
} }
start_offset = ftello(infile); start_offset = ftello(infile);
} else { } else {
/* 64-bit special case */ /* 64-bit special case */
if (atom_size == 1) { if (atom_size == 1) {
if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) { if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
......
...@@ -23,47 +23,50 @@ ...@@ -23,47 +23,50 @@
#include <inttypes.h> #include <inttypes.h>
static uint32_t state; static uint32_t state;
static uint32_t ran(void){ static uint32_t ran(void)
return state= state*1664525+1013904223; {
return state = state * 1664525 + 1013904223;
} }
int main(int argc, char** argv) int main(int argc, char **argv)
{ {
FILE *f; FILE *f;
int count, maxburst, length; int count, maxburst, length;
if (argc < 5){ if (argc < 5) {
printf("USAGE: trasher <filename> <count> <maxburst> <seed>\n"); printf("USAGE: trasher <filename> <count> <maxburst> <seed>\n");
return 1; return 1;
} }
f= fopen(argv[1], "rb+"); f = fopen(argv[1], "rb+");
if (!f){ if (!f) {
perror(argv[1]); perror(argv[1]);
return 2; return 2;
} }
count= atoi(argv[2]); count = atoi(argv[2]);
maxburst= atoi(argv[3]); maxburst = atoi(argv[3]);
state= atoi(argv[4]); state = atoi(argv[4]);
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
length= ftell(f); length = ftell(f);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
while(count--){ while (count--) {
int burst= 1 + ran() * (uint64_t) (abs(maxburst)-1) / UINT32_MAX; int burst = 1 + ran() * (uint64_t) (abs(maxburst) - 1) / UINT32_MAX;
int pos= ran() * (uint64_t) length / UINT32_MAX; int pos = ran() * (uint64_t) length / UINT32_MAX;
fseek(f, pos, SEEK_SET); fseek(f, pos, SEEK_SET);
if(maxburst<0) burst= -maxburst; if (maxburst < 0)
burst = -maxburst;
if(pos + burst > length) if (pos + burst > length)
continue; continue;
while(burst--){ while (burst--) {
int val= ran() * 256ULL / UINT32_MAX; int val = ran() * 256ULL / UINT32_MAX;
if(maxburst<0) val=0; if (maxburst < 0)
val = 0;
fwrite(&val, 1, 1, f); fwrite(&val, 1, 1, f);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment