* commit '1fb8f6a44f06e48386450fe0363aefc02583d24a': x86: lavr: add SSE2 quantize() for dithering doc/APIchanges: fill in missing dates and hashes. rtpdec_vp8: Request a keyframe if RTP packets are lost Conflicts: doc/APIchanges Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n1.2
| @@ -132,34 +132,34 @@ API changes, most recent first: | |||||
| 2012-03-26 - a67d9cf - lavfi 2.66.100 | 2012-03-26 - a67d9cf - lavfi 2.66.100 | ||||
| Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. | Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. | ||||
| 2013-xx-xx - xxxxxxx - lavr 1.1.0 | |||||
| 2013-01-07 - 074a00d - lavr 1.1.0 | |||||
| Add avresample_set_channel_mapping() for input channel reordering, | Add avresample_set_channel_mapping() for input channel reordering, | ||||
| duplication, and silencing. | duplication, and silencing. | ||||
| 2012-xx-xx - xxxxxxx - lavu 52.2.1 - avstring.h | |||||
| 2012-12-29 - d8fd06c - lavu 52.2.1 - avstring.h | |||||
| Add av_basename() and av_dirname(). | Add av_basename() and av_dirname(). | ||||
| 2012-11-10 - 5980f5dd - lavu 52.2.0 - audioconvert.h | |||||
| 2012-11-11 - 5980f5d - lavu 52.2.0 - audioconvert.h | |||||
| Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated. | Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated. | ||||
| 2012-10-26 - dfde8a34 - lavu 52.1.0 - intmath.h | |||||
| Add av_ctz() for trailing zero bit count. | |||||
| 2012-11-05 - dfde8a3 - lavu 52.1.0 - intmath.h | |||||
| Add av_ctz() for trailing zero bit count | |||||
| 2012-10-18 - a893655b - lavu 51.45.0 - error.h | |||||
| Add AVERROR_EXPERIMENTAL. | |||||
| 2012-10-21 - a893655 - lavu 51.45.0 - error.h | |||||
| Add AVERROR_EXPERIMENTAL | |||||
| 2012-10-12 - d2fcb356 - lavu 51.44.0 - pixdesc.h | |||||
| 2012-10-12 - d2fcb35 - lavu 51.44.0 - pixdesc.h | |||||
| Add functions for accessing pixel format descriptors. | Add functions for accessing pixel format descriptors. | ||||
| Accessing the av_pix_fmt_descriptors array directly is now | Accessing the av_pix_fmt_descriptors array directly is now | ||||
| deprecated. | deprecated. | ||||
| 2012-10-11 - 9a92aea2 - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h | |||||
| 2012-10-11 - 9a92aea - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h | |||||
| Add functions for allocating the opaque contexts for the algorithms, | Add functions for allocating the opaque contexts for the algorithms, | ||||
| 2012-10-10 - b522000e - lavf 54.18.0 - avio.h | |||||
| 2012-10-10 - b522000 - lavf 54.18.0 - avio.h | |||||
| Add avio_closep to complement avio_close. | Add avio_closep to complement avio_close. | ||||
| 2012-10-06 - 78071a14 - lavu 51.42.0 - pixfmt.h | |||||
| 2012-10-08 - 78071a1 - lavu 51.42.0 - pixfmt.h | |||||
| Rename PixelFormat to AVPixelFormat and all PIX_FMT_* to AV_PIX_FMT_*. | Rename PixelFormat to AVPixelFormat and all PIX_FMT_* to AV_PIX_FMT_*. | ||||
| To provide backwards compatibility, PixelFormat is now #defined as | To provide backwards compatibility, PixelFormat is now #defined as | ||||
| AVPixelFormat. | AVPixelFormat. | ||||
| @@ -35,11 +35,21 @@ struct PayloadContext { | |||||
| AVIOContext *data; | AVIOContext *data; | ||||
| uint32_t timestamp; | uint32_t timestamp; | ||||
| int is_keyframe; | int is_keyframe; | ||||
| /* If sequence_ok is set, we keep returning data (even if we might have | |||||
| * lost some data, but we haven't lost any too critical data that would | |||||
| * cause the decoder to desynchronize and output random garbage). | |||||
| */ | |||||
| int sequence_ok; | int sequence_ok; | ||||
| int first_part_size; | int first_part_size; | ||||
| uint16_t prev_seq; | uint16_t prev_seq; | ||||
| int prev_pictureid; | int prev_pictureid; | ||||
| int broken_frame; | int broken_frame; | ||||
| /* If sequence_dirty is set, we have lost some data (critical or | |||||
| * non-critical) and decoding will have some sort of artefacts, and | |||||
| * we thus should request a new keyframe. | |||||
| */ | |||||
| int sequence_dirty; | |||||
| int got_keyframe; | |||||
| }; | }; | ||||
| static void vp8_free_buffer(PayloadContext *vp8) | static void vp8_free_buffer(PayloadContext *vp8) | ||||
| @@ -141,11 +151,15 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, | |||||
| vp8_free_buffer(vp8); | vp8_free_buffer(vp8); | ||||
| // Keyframe, decoding ok again | // Keyframe, decoding ok again | ||||
| vp8->sequence_ok = 1; | vp8->sequence_ok = 1; | ||||
| vp8->sequence_dirty = 0; | |||||
| vp8->got_keyframe = 1; | |||||
| } else { | } else { | ||||
| int can_continue = vp8->data && !vp8->is_keyframe && | int can_continue = vp8->data && !vp8->is_keyframe && | ||||
| avio_tell(vp8->data) >= vp8->first_part_size; | avio_tell(vp8->data) >= vp8->first_part_size; | ||||
| if (!vp8->sequence_ok) | if (!vp8->sequence_ok) | ||||
| return AVERROR(EAGAIN); | return AVERROR(EAGAIN); | ||||
| if (!vp8->got_keyframe) | |||||
| return vp8_broken_sequence(ctx, vp8, "Keyframe missing\n"); | |||||
| if (pictureid >= 0) { | if (pictureid >= 0) { | ||||
| if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) { | if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) { | ||||
| return vp8_broken_sequence(ctx, vp8, | return vp8_broken_sequence(ctx, vp8, | ||||
| @@ -179,6 +193,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, | |||||
| } | } | ||||
| } | } | ||||
| if (vp8->data) { | if (vp8->data) { | ||||
| vp8->sequence_dirty = 1; | |||||
| if (avio_tell(vp8->data) >= vp8->first_part_size) { | if (avio_tell(vp8->data) >= vp8->first_part_size) { | ||||
| int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); | int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); | ||||
| if (ret < 0) | if (ret < 0) | ||||
| @@ -220,6 +235,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, | |||||
| "Missed part of a keyframe, sequence broken\n"); | "Missed part of a keyframe, sequence broken\n"); | ||||
| } else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) { | } else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) { | ||||
| vp8->broken_frame = 1; | vp8->broken_frame = 1; | ||||
| vp8->sequence_dirty = 1; | |||||
| } else { | } else { | ||||
| return vp8_broken_sequence(ctx, vp8, | return vp8_broken_sequence(ctx, vp8, | ||||
| "Missed part of the first partition, sequence broken\n"); | "Missed part of the first partition, sequence broken\n"); | ||||
| @@ -253,7 +269,11 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, | |||||
| static PayloadContext *vp8_new_context(void) | static PayloadContext *vp8_new_context(void) | ||||
| { | { | ||||
| return av_mallocz(sizeof(PayloadContext)); | |||||
| PayloadContext *vp8 = av_mallocz(sizeof(PayloadContext)); | |||||
| if (!vp8) | |||||
| return NULL; | |||||
| vp8->sequence_ok = 1; | |||||
| return vp8; | |||||
| } | } | ||||
| static void vp8_free_context(PayloadContext *vp8) | static void vp8_free_context(PayloadContext *vp8) | ||||
| @@ -262,6 +282,11 @@ static void vp8_free_context(PayloadContext *vp8) | |||||
| av_free(vp8); | av_free(vp8); | ||||
| } | } | ||||
| static int vp8_need_keyframe(PayloadContext *vp8) | |||||
| { | |||||
| return vp8->sequence_dirty || !vp8->sequence_ok; | |||||
| } | |||||
| RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { | RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { | ||||
| .enc_name = "VP8", | .enc_name = "VP8", | ||||
| .codec_type = AVMEDIA_TYPE_VIDEO, | .codec_type = AVMEDIA_TYPE_VIDEO, | ||||
| @@ -269,4 +294,5 @@ RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { | |||||
| .alloc = vp8_new_context, | .alloc = vp8_new_context, | ||||
| .free = vp8_free_context, | .free = vp8_free_context, | ||||
| .parse_packet = vp8_handle_packet, | .parse_packet = vp8_handle_packet, | ||||
| .need_keyframe = vp8_need_keyframe, | |||||
| }; | }; | ||||
| @@ -336,6 +336,9 @@ static void dither_init(DitherDSPContext *ddsp, | |||||
| ddsp->dither_int_to_float = dither_int_to_float_rectangular_c; | ddsp->dither_int_to_float = dither_int_to_float_rectangular_c; | ||||
| else | else | ||||
| ddsp->dither_int_to_float = dither_int_to_float_triangular_c; | ddsp->dither_int_to_float = dither_int_to_float_triangular_c; | ||||
| if (ARCH_X86) | |||||
| ff_dither_init_x86(ddsp, method); | |||||
| } | } | ||||
| DitherContext *ff_dither_alloc(AVAudioResampleContext *avr, | DitherContext *ff_dither_alloc(AVAudioResampleContext *avr, | ||||
| @@ -85,4 +85,9 @@ void ff_dither_free(DitherContext **c); | |||||
| */ | */ | ||||
| int ff_convert_dither(DitherContext *c, AudioData *dst, AudioData *src); | int ff_convert_dither(DitherContext *c, AudioData *dst, AudioData *src); | ||||
| /* arch-specific initialization functions */ | |||||
| void ff_dither_init_x86(DitherDSPContext *ddsp, | |||||
| enum AVResampleDitherMethod method); | |||||
| #endif /* AVRESAMPLE_DITHER_H */ | #endif /* AVRESAMPLE_DITHER_H */ | ||||
| @@ -1,5 +1,7 @@ | |||||
| OBJS += x86/audio_convert_init.o \ | OBJS += x86/audio_convert_init.o \ | ||||
| x86/audio_mix_init.o \ | x86/audio_mix_init.o \ | ||||
| x86/dither_init.o \ | |||||
| YASM-OBJS += x86/audio_convert.o \ | YASM-OBJS += x86/audio_convert.o \ | ||||
| x86/audio_mix.o \ | x86/audio_mix.o \ | ||||
| x86/dither.o \ | |||||
| @@ -0,0 +1,53 @@ | |||||
| ;****************************************************************************** | |||||
| ;* x86 optimized dithering format conversion | |||||
| ;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com> | |||||
| ;* | |||||
| ;* This file is part of FFmpeg. | |||||
| ;* | |||||
| ;* FFmpeg is free software; you can redistribute it and/or | |||||
| ;* modify it under the terms of the GNU Lesser General Public | |||||
| ;* License as published by the Free Software Foundation; either | |||||
| ;* version 2.1 of the License, or (at your option) any later version. | |||||
| ;* | |||||
| ;* FFmpeg is distributed in the hope that it will be useful, | |||||
| ;* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| ;* Lesser General Public License for more details. | |||||
| ;* | |||||
| ;* You should have received a copy of the GNU Lesser General Public | |||||
| ;* License along with FFmpeg; if not, write to the Free Software | |||||
| ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||||
| ;****************************************************************************** | |||||
| %include "libavutil/x86/x86util.asm" | |||||
| SECTION_RODATA 32 | |||||
| pf_s16_scale: times 4 dd 32753.0 | |||||
| SECTION_TEXT | |||||
| ;------------------------------------------------------------------------------ | |||||
| ; void ff_quantize(int16_t *dst, float *src, float *dither, int len); | |||||
| ;------------------------------------------------------------------------------ | |||||
| INIT_XMM sse2 | |||||
| cglobal quantize, 4,4,3, dst, src, dither, len | |||||
| lea lenq, [2*lend] | |||||
| add dstq, lenq | |||||
| lea srcq, [srcq+2*lenq] | |||||
| lea ditherq, [ditherq+2*lenq] | |||||
| neg lenq | |||||
| mova m2, [pf_s16_scale] | |||||
| .loop: | |||||
| mulps m0, m2, [srcq+2*lenq] | |||||
| mulps m1, m2, [srcq+2*lenq+mmsize] | |||||
| addps m0, [ditherq+2*lenq] | |||||
| addps m1, [ditherq+2*lenq+mmsize] | |||||
| cvtps2dq m0, m0 | |||||
| cvtps2dq m1, m1 | |||||
| packssdw m0, m1 | |||||
| mova [dstq+lenq], m0 | |||||
| add lenq, mmsize | |||||
| jl .loop | |||||
| REP_RET | |||||
| @@ -0,0 +1,39 @@ | |||||
| /* | |||||
| * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com> | |||||
| * | |||||
| * This file is part of FFmpeg. | |||||
| * | |||||
| * FFmpeg is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU Lesser General Public | |||||
| * License as published by the Free Software Foundation; either | |||||
| * version 2.1 of the License, or (at your option) any later version. | |||||
| * | |||||
| * FFmpeg is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||||
| * Lesser General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU Lesser General Public | |||||
| * License along with FFmpeg; if not, write to the Free Software | |||||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||||
| */ | |||||
| #include "config.h" | |||||
| #include "libavutil/cpu.h" | |||||
| #include "libavutil/x86/cpu.h" | |||||
| #include "libavresample/dither.h" | |||||
| extern void ff_quantize_sse2(int16_t *dst, const float *src, float *dither, | |||||
| int len); | |||||
| av_cold void ff_dither_init_x86(DitherDSPContext *ddsp, | |||||
| enum AVResampleDitherMethod method) | |||||
| { | |||||
| int mm_flags = av_get_cpu_flags(); | |||||
| if (EXTERNAL_SSE2(mm_flags)) { | |||||
| ddsp->quantize = ff_quantize_sse2; | |||||
| ddsp->ptr_align = 16; | |||||
| ddsp->samples_align = 8; | |||||
| } | |||||
| } | |||||