[FFmpeg-cvslog] lavfi/vf_decimate: do not compare the first frame to itself.
ffmpeg | branch: master | Nicolas George | Sat Oct 24 19:43:55 2015 +0200| [962727acb4e3c4dff856b48460ddcf747fcfda93] | committer: Nicolas George lavfi/vf_decimate: do not compare the first frame to itself. This is a waste of computing power and will result to 0, making it always dropped. Use maximum difference values instead. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=962727acb4e3c4dff856b48460ddcf747fcfda93 --- libavfilter/vf_decimate.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c index cd374c3..8b950b4 100644 --- a/libavfilter/vf_decimate.c +++ b/libavfilter/vf_decimate.c @@ -167,9 +167,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (in) { /* update frame metrics */ prv = dm->fid ? dm->queue[dm->fid - 1].frame : dm->last; -if (!prv) -prv = in; -calc_diffs(dm, &dm->queue[dm->fid], prv, in); +if (!prv) { +dm->queue[dm->fid].maxbdiff = INT64_MAX; +dm->queue[dm->fid].totdiff = INT64_MAX; +} else { +calc_diffs(dm, &dm->queue[dm->fid], prv, in); +} if (++dm->fid != dm->cycle) return 0; av_frame_free(&dm->last); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/ffmdec: Add {} to nested if/else
ffmpeg | branch: master | Michael Niedermayer | Sun Jan 3 15:47:23 2016 +0100| [97c162add7f33f4f8c82b1f873830d96e04ab06a] | committer: Michael Niedermayer avformat/ffmdec: Add {} to nested if/else This preempts potential bugs if this is changed and the indention ends up different from C interpretation Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=97c162add7f33f4f8c82b1f873830d96e04ab06a --- libavformat/ffmdec.c |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index 7f31d14..ecb4229 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -100,11 +100,12 @@ static int ffm_read_data(AVFormatContext *s, if (len > size) len = size; if (len == 0) { -if (avio_tell(pb) == ffm->file_size) -if (ffm->server_attached) +if (avio_tell(pb) == ffm->file_size) { +if (ffm->server_attached) { avio_seek(pb, ffm->packet_size, SEEK_SET); -else +} else return AVERROR_EOF; +} retry_read: if (pb->buffer_size != ffm->packet_size) { int64_t tell = avio_tell(pb); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffmdec: reset packet_end in case of failure
ffmpeg | branch: master | Andreas Cadhalpun | Sat Jan 2 16:27:02 2016 +0100| [40eb2531b279abe008012c5c2c292552d3e62449] | committer: Andreas Cadhalpun ffmdec: reset packet_end in case of failure This fixes segmentation faults caused by passing a packet_ptr of NULL to memcpy. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Cadhalpun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40eb2531b279abe008012c5c2c292552d3e62449 --- libavformat/ffmdec.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index ecb4229..f754895 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -124,9 +124,10 @@ static int ffm_read_data(AVFormatContext *s, ffm->dts = avio_rb64(pb); frame_offset = avio_rb16(pb); avio_read(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE); -ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size); -if (ffm->packet_end < ffm->packet || frame_offset < 0) +if (ffm->packet_size < FFM_HEADER_SIZE + fill_size || frame_offset < 0) { return -1; +} +ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size); /* if first packet or resynchronization packet, we must handle it specifically */ if (ffm->first_packet || (frame_offset & 0x8000)) { @@ -142,8 +143,10 @@ static int ffm_read_data(AVFormatContext *s, return 0; } ffm->first_packet = 0; -if ((frame_offset & 0x7fff) < FFM_HEADER_SIZE) +if ((frame_offset & 0x7fff) < FFM_HEADER_SIZE) { +ffm->packet_end = ffm->packet_ptr; return -1; +} ffm->packet_ptr = ffm->packet + (frame_offset & 0x7fff) - FFM_HEADER_SIZE; if (!header) break; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] get_bits: add get_bitsz for reading 0-25 bits
ffmpeg | branch: master | Andreas Cadhalpun | Sun Jan 3 00:28:42 2016 +0100| [713654d9d3a6931a9b4cd0cffa4bb61cd1357977] | committer: Andreas Cadhalpun get_bits: add get_bitsz for reading 0-25 bits This can be used to simplify code in a couple of places. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Cadhalpun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=713654d9d3a6931a9b4cd0cffa4bb61cd1357977 --- libavcodec/get_bits.h |8 libavcodec/mpegaudiodec_template.c |7 --- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h index 0a61c80..4cf61d6 100644 --- a/libavcodec/get_bits.h +++ b/libavcodec/get_bits.h @@ -269,6 +269,14 @@ static inline unsigned int get_bits(GetBitContext *s, int n) return tmp; } +/** + * Read 0-25 bits. + */ +static av_always_inline int get_bitsz(GetBitContext *s, int n) +{ +return n ? get_bits(s, n) : 0; +} + static inline unsigned int get_bits_le(GetBitContext *s, int n) { register int tmp; diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index d2420c1..5e3fe7e 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -816,13 +816,6 @@ static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, } } -/* handle n = 0 too */ -static inline int get_bitsz(GetBitContext *s, int n) -{ -return n ? get_bits(s, n) : 0; -} - - static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc: use get_bitsz to simplify the code
ffmpeg | branch: master | Andreas Cadhalpun | Sun Jan 3 01:19:23 2016 +0100| [43ff4aed26cba2cce230972add631ab938d33b30] | committer: Andreas Cadhalpun lavc: use get_bitsz to simplify the code Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Cadhalpun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=43ff4aed26cba2cce230972add631ab938d33b30 --- libavcodec/atrac3plus.c | 13 + libavcodec/escape124.c |2 +- libavcodec/hevc.c |2 +- libavcodec/hevc_parser.c|2 +- libavcodec/wavpack.c|2 +- libavcodec/wmalosslessdec.c |7 +++ libavcodec/wmaprodec.c |2 +- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/libavcodec/atrac3plus.c b/libavcodec/atrac3plus.c index b16a139..46e0bea 100644 --- a/libavcodec/atrac3plus.c +++ b/libavcodec/atrac3plus.c @@ -39,9 +39,6 @@ static VLC spec_vlc_tabs[112]; static VLC gain_vlc_tabs[11]; static VLC tone_vlc_tabs[7]; -#define GET_DELTA(gb, delta_bits) \ -((delta_bits) ? get_bits((gb), (delta_bits)) : 0) - /** * Generate canonical VLC table from given descriptor. * @@ -384,7 +381,7 @@ static int decode_channel_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, chan->qu_wordlen[i] = get_bits(gb, 3); for (i = pos; i < chan->num_coded_vals; i++) -chan->qu_wordlen[i] = (min_val + GET_DELTA(gb, delta_bits)) & 7; +chan->qu_wordlen[i] = (min_val + get_bitsz(gb, delta_bits)) & 7; } } break; @@ -516,7 +513,7 @@ static int decode_channel_sf_idx(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, /* all others are: min_val + delta */ for (i = num_long_vals; i < ctx->used_quant_units; i++) chan->qu_sf_idx[i] = (chan->qu_sf_idx[i] + min_val + - GET_DELTA(gb, delta_bits)) & 0x3F; + get_bitsz(gb, delta_bits)) & 0x3F; } else { num_long_vals = get_bits(gb, 5); delta_bits= get_bits(gb, 3); @@ -534,7 +531,7 @@ static int decode_channel_sf_idx(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, /* all others are: min_val + delta */ for (i = num_long_vals; i < ctx->used_quant_units; i++) chan->qu_sf_idx[i] = (min_val + - GET_DELTA(gb, delta_bits)) & 0x3F; + get_bitsz(gb, delta_bits)) & 0x3F; } } break; @@ -1014,7 +1011,7 @@ static int decode_gainc_npoints(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, min_val= get_bits(gb, 3); for (i = 0; i < coded_subbands; i++) { -chan->gain_data[i].num_points = min_val + GET_DELTA(gb, delta_bits); +chan->gain_data[i].num_points = min_val + get_bitsz(gb, delta_bits); if (chan->gain_data[i].num_points > 7) return AVERROR_INVALIDDATA; } @@ -1134,7 +1131,7 @@ static int decode_gainc_levels(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, for (sb = 0; sb < coded_subbands; sb++) for (i = 0; i < chan->gain_data[sb].num_points; i++) { -chan->gain_data[sb].lev_code[i] = min_val + GET_DELTA(gb, delta_bits); +chan->gain_data[sb].lev_code[i] = min_val + get_bitsz(gb, delta_bits); if (chan->gain_data[sb].lev_code[i] > 15) return AVERROR_INVALIDDATA; } diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index efcac64..50a86c8 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -155,7 +155,7 @@ static MacroBlock decode_macroblock(Escape124Context* s, GetBitContext* gb, // depth = 0 means that this shouldn't read any bits; // in theory, this is the same as get_bits(gb, 0), but // that doesn't actually work. -block_index = depth ? get_bits(gb, depth) : 0; +block_index = get_bitsz(gb, depth); if (*codebook_index == 1) { block_index += superblock_index << s->codebooks[1].depth; diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index 33c6ee2..c245d3b 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -469,7 +469,7 @@ static int hls_slice_header(HEVCContext *s) slice_address_length = av_ceil_log2(s->ps.sps->ctb_width * s->ps.sps->ctb_height); -sh->slice_segment_addr = slice_address_length ? get_bits(gb, slice_address_length) : 0; +sh->slice_segment_addr = get_bitsz(gb, slice_address_length); if (sh->slice_segment_addr >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) { av_log(s->avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", diff --git a/libavcodec/hevc_parser.c b/l
[FFmpeg-cvslog] lavfi/drawtext: Fix microsecond display.
ffmpeg | branch: master | Carl Eugen Hoyos | Sun Jan 3 22:55:31 2016 +0100| [ae9f2e6f2813ab78b7b4e11ac80dd1a2abec5c25] | committer: Carl Eugen Hoyos lavfi/drawtext: Fix microsecond display. Fixes ticket #4792. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae9f2e6f2813ab78b7b4e11ac80dd1a2abec5c25 --- libavfilter/vf_drawtext.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index e96bfb6..1ef3ecb 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -824,7 +824,7 @@ static int func_pts(AVFilterContext *ctx, AVBPrint *bp, (int)(ms / (60 * 60 * 1000)), (int)(ms / (60 * 1000)) % 60, (int)(ms / 1000) % 60, - (int)ms % 1000); + (int)(ms % 1000)); } } else if (!strcmp(fmt, "localtime") || !strcmp(fmt, "gmtime")) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avfilter/avf_showspectrum: switch to FFT
ffmpeg | branch: master | Paul B Mahol | Sun Jan 3 22:03:10 2016 +0100| [14caf9667e3f588d6497b68f3c0ab3b6592d328b] | committer: Paul B Mahol avfilter/avf_showspectrum: switch to FFT Rationale: supports >16 bit audio, more than 96dB SNR. Signed-off-by: Paul B Mahol > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=14caf9667e3f588d6497b68f3c0ab3b6592d328b --- libavfilter/avf_showspectrum.c | 90 +--- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index d9fae7f..6e73b9e 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -59,9 +59,9 @@ typedef struct { int scale; float saturation; ///< color saturation multiplier int xpos; ///< x position (current column) -RDFTContext *rdft; ///< Real Discrete Fourier Transform context -int rdft_bits; ///< number of bits (RDFT window size = 1rdft); -if (s->rdft_data) { +av_fft_end(s->fft); +if (s->fft_data) { for (i = 0; i < s->nb_display_channels; i++) -av_freep(&s->rdft_data[i]); +av_freep(&s->fft_data[i]); } -av_freep(&s->rdft_data); +av_freep(&s->fft_data); av_freep(&s->window_func_lut); if (s->magnitudes) { for (i = 0; i < s->nb_display_channels; i++) @@ -217,7 +217,7 @@ static int query_formats(AVFilterContext *ctx) AVFilterChannelLayouts *layouts = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; -static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }; +static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE }; int ret; @@ -247,7 +247,7 @@ static int config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; AVFilterLink *inlink = ctx->inputs[0]; ShowSpectrumContext *s = ctx->priv; -int i, rdft_bits, h, w; +int i, fft_bits, h, w; float overlap; if (!strcmp(ctx->filter->name, "showspectrumpic")) @@ -262,33 +262,33 @@ static int config_output(AVFilterLink *outlink) s->channel_width = w; if (s->orientation == VERTICAL) { -/* RDFT window size (precision) according to the requested output frame height */ -for (rdft_bits = 1; 1 << rdft_bits < 2 * h; rdft_bits++); +/* FFT window size (precision) according to the requested output frame height */ +for (fft_bits = 1; 1 << fft_bits < 2 * h; fft_bits++); } else { -/* RDFT window size (precision) according to the requested output frame width */ -for (rdft_bits = 1; 1 << rdft_bits < 2 * w; rdft_bits++); +/* FFT window size (precision) according to the requested output frame width */ +for (fft_bits = 1; 1 << fft_bits < 2 * w; fft_bits++); } -s->win_size = 1 << rdft_bits; +s->win_size = 1 << fft_bits; /* (re-)configuration if the video output changed (or first init) */ -if (rdft_bits != s->rdft_bits) { +if (fft_bits != s->fft_bits) { AVFrame *outpicref; -av_rdft_end(s->rdft); -s->rdft = av_rdft_init(rdft_bits, DFT_R2C); -if (!s->rdft) { -av_log(ctx, AV_LOG_ERROR, "Unable to create RDFT context. " +av_fft_end(s->fft); +s->fft = av_fft_init(fft_bits, 0); +if (!s->fft) { +av_log(ctx, AV_LOG_ERROR, "Unable to create FFT context. " "The window size might be too high.\n"); return AVERROR(EINVAL); } -s->rdft_bits = rdft_bits; +s->fft_bits = fft_bits; -/* RDFT buffers: x2 for each (display) channel buffer. +/* FFT buffers: x2 for each (display) channel buffer. * Note: we use free and malloc instead of a realloc-like function to * make sure the buffer is aligned in memory for the FFT functions. */ for (i = 0; i < s->nb_display_channels; i++) -av_freep(&s->rdft_data[i]); -av_freep(&s->rdft_data); +av_freep(&s->fft_data[i]); +av_freep(&s->fft_data); s->nb_display_channels = inlink->channels; s->magnitudes = av_calloc(s->nb_display_channels, sizeof(*s->magnitudes)); @@ -300,12 +300,12 @@ static int config_output(AVFilterLink *outlink) return AVERROR(ENOMEM); } -s->rdft_data = av_calloc(s->nb_display_channels, sizeof(*s->rdft_data)); -if (!s->rdft_data) +s->fft_data = av_calloc(s->nb_display_channels, sizeof(*s->fft_data)); +if (!s->fft_data) return AVERROR(ENOMEM); for (i = 0; i < s->nb_display_channels; i++) { -s->rdft_data[i] = av_calloc(s->win_size, sizeof(**s->rd
[FFmpeg-cvslog] avfilter/avf_showspectrum: finally fix log scaler
ffmpeg | branch: master | Paul B Mahol | Sun Jan 3 22:43:21 2016 +0100| [0a451082c774540f8d47642d2078fcf2c822ebc1] | committer: Paul B Mahol avfilter/avf_showspectrum: finally fix log scaler Signed-off-by: Paul B Mahol > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0a451082c774540f8d47642d2078fcf2c822ebc1 --- libavfilter/avf_showspectrum.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 6e73b9e..48d811e 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -581,7 +581,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) a = pow(a, 0.20); break; case LOG: -a = 1 + log10(FFMAX(FFMIN(1, a), 1e-6)) / 5; // zero = -120dBFS +a = 1 + log10(FFMAX(FFMIN(1, a * w), 1e-6)) / 6; // zero = -120dBFS break; default: av_assert0(0); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] vorbisdec: reject channel mapping with less than two channels
ffmpeg | branch: master | Andreas Cadhalpun | Sun Jan 3 19:20:54 2016 +0100| [b4b13848dec5420fa5dd9e1a7d4dfae5de1932d5] | committer: Andreas Cadhalpun vorbisdec: reject channel mapping with less than two channels It causes the angle channel number to equal the magnitude channel number, which makes the stream undecodable according to the specification. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Cadhalpun > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b4b13848dec5420fa5dd9e1a7d4dfae5de1932d5 --- libavcodec/vorbisdec.c |5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index f773afa..4dd47ac 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -789,6 +789,11 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc) if (get_bits1(gb)) { mapping_setup->coupling_steps = get_bits(gb, 8) + 1; +if (vc->audio_channels < 2) { +av_log(vc->avctx, AV_LOG_ERROR, + "Square polar channel mapping with less than two channels is not compliant with the Vorbis I specification.\n"); +return AVERROR_INVALIDDATA; +} mapping_setup->magnitude = av_mallocz(mapping_setup->coupling_steps * sizeof(*mapping_setup->magnitude)); mapping_setup->angle = av_mallocz(mapping_setup->coupling_steps * ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/h264: Fix regression caused by removial of default_ref_list
ffmpeg | branch: master | Michael Niedermayer | Sun Jan 3 18:48:45 2016 +0100| [4da2ac5c7a491b20be62ad19d77526e62aa57c69] | committer: Michael Niedermayer avcodec/h264: Fix regression caused by removial of default_ref_list This fixes a regression of the sample from Ticket 2371 Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4da2ac5c7a491b20be62ad19d77526e62aa57c69 --- libavcodec/h264.h |1 + libavcodec/h264_refs.c | 11 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 5d9aecd..a5fc3a0 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -669,6 +669,7 @@ typedef struct H264Context { */ int max_pic_num; +H264Ref default_ref[2]; H264Picture *short_ref[32]; H264Picture *long_ref[32]; H264Picture *delayed_pic[MAX_DELAYED_PIC_COUNT + 2]; // FIXME size? diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index 52fedc1..f42d6a2 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -208,6 +208,8 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl) } } } +for (i = 0; i < sl->list_count; i++) +h->default_ref[i] = sl->ref_list[i][0]; } static void print_short_term(H264Context *h); @@ -351,10 +353,14 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl) if ( !sl->ref_list[list][index].parent || (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) { int i; -av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture\n"); +av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref[list].poc); for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++) h->last_pocs[i] = INT_MIN; -return -1; +if (h->default_ref[list].parent +&& !(!FIELD_PICTURE(h) && (h->default_ref[list].reference&3) != 3)) +sl->ref_list[list][index] = h->default_ref[list]; +else +return -1; } av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f->buf[0]) > 0); } @@ -524,6 +530,7 @@ void ff_h264_remove_all_refs(H264Context *h) } h->short_ref_count = 0; +memset(h->default_ref, 0, sizeof(h->default_ref)); for (i = 0; i < h->nb_slice_ctx; i++) { H264SliceContext *sl = &h->slice_ctx[i]; sl->list_count = sl->ref_count[0] = sl->ref_count[1] = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/qtpalette: Ignore greyscale bit in certain cases
ffmpeg | branch: master | Mats Peterson | Sat Jan 2 06:30:22 2016 +0100| [b6c61b7d43fa6f01555305cca0717901838f2331] | committer: Michael Niedermayer lavf/qtpalette: Ignore greyscale bit in certain cases The QuickTime File Format Specification states the following: "Depth: A 16-bit integer that indicates the pixel depth of the compressed image. Values of 1, 2, 4, 8 ,16, 24, and 32 indicate the depth of color images. The value 32 should be used only if the image contains an alpha channel. Values of 34, 36, and 40 indicate 2-, 4-, and 8-bit grayscale, respectively, for grayscale images." There is no mention of value 33, i.e. 1-bit video (0x01) with the greyscale bit (0x20) set. I therefore suggest that we ignore the greyscale bit when processing 1-bit video. Another reason to do this is that the first 1-bit sample file below will be displayed properly with blue colors in QuickTime in Windows or Mac *in spite of* the greyscale bit being set. Also, QuickTime in Windows or Mac ignores the greyscale bit if the video sample description contains a palette, regardless of bit depth. This is undocumented behaviour, but I think we should do the same, and it seems pretty logical after all, since one wouldn't really bother putting a customized palette into a grayscale file anyway. See the second 8-bit sample file below, which has the greyscale bit set, and which contains a palette in the video sample description. In Windows or Mac, it will be displayed with the palette in the sample description, in spite of the greyscale bit being set. Sample file 1 (1-bit QuickTime Animation): https://drive.google.com/open?id=0B3_pEBoLs0faTThSek1EeXQ0ZHM Earth Spin 1-bit qtrle orig.mov Sample file 2 (8-bit QuickTime Animation): https://drive.google.com/open?id=0B3_pEBoLs0fad2s0V1YzUWo5aDA quiz-palette+gs.mov Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b6c61b7d43fa6f01555305cca0717901838f2331 --- libavformat/qtpalette.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/qtpalette.c b/libavformat/qtpalette.c index 6544a55..a78b6af 100644 --- a/libavformat/qtpalette.c +++ b/libavformat/qtpalette.c @@ -51,7 +51,9 @@ int ff_get_qtpalette(int codec_id, AVIOContext *pb, uint32_t *palette) int color_count, color_start, color_end; uint32_t a, r, g, b; -if (greyscale) { +/* Ignore the greyscale bit for 1-bit video and sample + * descriptions containing a color table. */ +if (greyscale && bit_depth > 1 && color_table_id) { int color_index, color_dec; /* compute the greyscale palette */ color_count = 1 << bit_depth; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc/qtrle: Use AV_PIX_FMT_PAL8 for 1-bit video
ffmpeg | branch: master | Mats Peterson | Tue Dec 29 22:50:56 2015 +0100| [bf42a7ef6d073221915dcc042c080374045ab245] | committer: Michael Niedermayer lavc/qtrle: Use AV_PIX_FMT_PAL8 for 1-bit video This commit fixes the lack of palettized display of 1-bit video in the qtrle decoder. It is related to my commit of lavf/qtpalette, which added 1-bit video to the "palettized video" category. As far as I can see, everything works fine, but comments are of course welcome. Below are links to sample files, which should now be displayed properly with bluish colors, but which were previously displayed in black & white. Matroska: https://drive.google.com/open?id=0B3_pEBoLs0faNjI0cHBMWDhYY2c Earth Spin 1-bit qtrle.mkv QuickTime (mov): https://drive.google.com/open?id=0B3_pEBoLs0faUlItWm9KaGJSTEE Earth Spin 1-bit qtrle.mov Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bf42a7ef6d073221915dcc042c080374045ab245 --- libavcodec/qtrle.c| 45 --- tests/ref/fate/qtrle-1bit | 76 ++--- 2 files changed, 71 insertions(+), 50 deletions(-) diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c index 1fcf5b3..3f482f4 100644 --- a/libavcodec/qtrle.c +++ b/libavcodec/qtrle.c @@ -83,9 +83,9 @@ static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change) if(skip & 0x80) { lines_to_change--; row_ptr += row_inc; -pixel_ptr = row_ptr + 2 * (skip & 0x7f); +pixel_ptr = row_ptr + 2 * 8 * (skip & 0x7f); } else -pixel_ptr += 2 * skip; +pixel_ptr += 2 * 8 * skip; CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */ if(rle_code == -1) @@ -99,19 +99,42 @@ static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change) pi0 = bytestream2_get_byte(&s->g); pi1 = bytestream2_get_byte(&s->g); -CHECK_PIXEL_PTR(rle_code * 2); +CHECK_PIXEL_PTR(rle_code * 2 * 8); while (rle_code--) { -rgb[pixel_ptr++] = pi0; -rgb[pixel_ptr++] = pi1; +rgb[pixel_ptr++] = (pi0 >> 7) & 0x01; +rgb[pixel_ptr++] = (pi0 >> 6) & 0x01; +rgb[pixel_ptr++] = (pi0 >> 5) & 0x01; +rgb[pixel_ptr++] = (pi0 >> 4) & 0x01; +rgb[pixel_ptr++] = (pi0 >> 3) & 0x01; +rgb[pixel_ptr++] = (pi0 >> 2) & 0x01; +rgb[pixel_ptr++] = (pi0 >> 1) & 0x01; +rgb[pixel_ptr++] = pi0 & 0x01; +rgb[pixel_ptr++] = (pi1 >> 7) & 0x01; +rgb[pixel_ptr++] = (pi1 >> 6) & 0x01; +rgb[pixel_ptr++] = (pi1 >> 5) & 0x01; +rgb[pixel_ptr++] = (pi1 >> 4) & 0x01; +rgb[pixel_ptr++] = (pi1 >> 3) & 0x01; +rgb[pixel_ptr++] = (pi1 >> 2) & 0x01; +rgb[pixel_ptr++] = (pi1 >> 1) & 0x01; +rgb[pixel_ptr++] = pi1 & 0x01; } } else { /* copy the same pixel directly to output 2 times */ rle_code *= 2; -CHECK_PIXEL_PTR(rle_code); +CHECK_PIXEL_PTR(rle_code * 8); -bytestream2_get_buffer(&s->g, &rgb[pixel_ptr], rle_code); -pixel_ptr += rle_code; +while (rle_code--) { +int x = bytestream2_get_byte(&s->g); +rgb[pixel_ptr++] = (x >> 7) & 0x01; +rgb[pixel_ptr++] = (x >> 6) & 0x01; +rgb[pixel_ptr++] = (x >> 5) & 0x01; +rgb[pixel_ptr++] = (x >> 4) & 0x01; +rgb[pixel_ptr++] = (x >> 3) & 0x01; +rgb[pixel_ptr++] = (x >> 2) & 0x01; +rgb[pixel_ptr++] = (x >> 1) & 0x01; +rgb[pixel_ptr++] = x & 0x01; +} } } } @@ -364,13 +387,10 @@ static av_cold int qtrle_decode_init(AVCodecContext *avctx) s->avctx = avctx; switch (avctx->bits_per_coded_sample) { case 1: -case 33: -avctx->pix_fmt = AV_PIX_FMT_MONOWHITE; -break; - case 2: case 4: case 8: +case 33: case 34: case 36: case 40: @@ -446,6 +466,7 @@ static int qtrle_decode_frame(AVCodecContext *avctx, case 1: case 33: qtrle_decode_1bpp(s, row_ptr, height); +has_palette = 1; break; case 2: diff --git a/tests/ref/fate/qtrle-1bit b/tests/ref/fate/qtrle-1bit index f191169..3eccc27 100644 --- a/tests/ref/fate/qtrle-1bit +++ b/tests/ref/fate/qtrle-1bit @@ -1,39 +1,39 @@ #tb 0: 1/12 -0, 0, 0,1, 9600, 0xc5921aa2 -0, 1, 1,1, 9600, 0x9032fc52 -0, 2, 2,1, 9600, 0x7db0038e -0, 3, 3,1, 9600, 0x95b73c41 -0, 4, 4,1, 9600, 0x531e4189 -0, 5,