* 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
Unified · Split
| @@ -132,34 +132,34 @@ API changes, most recent first: · 131 unmodified lines | ||
| 132 | 132 | 2012-03-26 - a67d9cf - lavfi 2.66.100 |
| 133 | 133 | Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. |
| 134 | 134 | |
| 135 | −2013-xx-xx - xxxxxxx - lavr 1.1.0 | |
| 135 | +2013-01-07 - 074a00d - lavr 1.1.0 | |
| 136 | 136 | Add avresample_set_channel_mapping() for input channel reordering, |
| 137 | 137 | duplication, and silencing. |
| 138 | 138 | |
| 139 | −2012-xx-xx - xxxxxxx - lavu 52.2.1 - avstring.h | |
| 139 | +2012-12-29 - d8fd06c - lavu 52.2.1 - avstring.h | |
| 140 | 140 | Add av_basename() and av_dirname(). |
| 141 | 141 | |
| 142 | −2012-11-10 - 5980f5dd - lavu 52.2.0 - audioconvert.h | |
| 142 | +2012-11-11 - 5980f5d - lavu 52.2.0 - audioconvert.h | |
| 143 | 143 | Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated. |
| 144 | 144 | |
| 145 | −2012-10-26 - dfde8a34 - lavu 52.1.0 - intmath.h | |
| 146 | − Add av_ctz() for trailing zero bit count. | |
| 145 | +2012-11-05 - dfde8a3 - lavu 52.1.0 - intmath.h | |
| 146 | + Add av_ctz() for trailing zero bit count | |
| 147 | 147 | |
| 148 | −2012-10-18 - a893655b - lavu 51.45.0 - error.h | |
| 149 | − Add AVERROR_EXPERIMENTAL. | |
| 148 | +2012-10-21 - a893655 - lavu 51.45.0 - error.h | |
| 149 | + Add AVERROR_EXPERIMENTAL | |
| 150 | 150 | |
| 151 | −2012-10-12 - d2fcb356 - lavu 51.44.0 - pixdesc.h | |
| 151 | +2012-10-12 - d2fcb35 - lavu 51.44.0 - pixdesc.h | |
| 152 | 152 | Add functions for accessing pixel format descriptors. |
| 153 | 153 | Accessing the av_pix_fmt_descriptors array directly is now |
| 154 | 154 | deprecated. |
| 155 | 155 | |
| 156 | −2012-10-11 - 9a92aea2 - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h | |
| 156 | +2012-10-11 - 9a92aea - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h | |
| 157 | 157 | Add functions for allocating the opaque contexts for the algorithms, |
| 158 | 158 | |
| 159 | −2012-10-10 - b522000e - lavf 54.18.0 - avio.h | |
| 159 | +2012-10-10 - b522000 - lavf 54.18.0 - avio.h | |
| 160 | 160 | Add avio_closep to complement avio_close. |
| 161 | 161 | |
| 162 | −2012-10-06 - 78071a14 - lavu 51.42.0 - pixfmt.h | |
| 162 | +2012-10-08 - 78071a1 - lavu 51.42.0 - pixfmt.h | |
| 163 | 163 | Rename PixelFormat to AVPixelFormat and all PIX_FMT_* to AV_PIX_FMT_*. |
| 164 | 164 | To provide backwards compatibility, PixelFormat is now #defined as |
| 165 | 165 | AVPixelFormat. |
| @@ -35,11 +35,21 @@ struct PayloadContext { · 34 unmodified lines | ||
| 35 | 35 | AVIOContext *data; |
| 36 | 36 | uint32_t timestamp; |
| 37 | 37 | int is_keyframe; |
| 38 | + /* If sequence_ok is set, we keep returning data (even if we might have | |
| 39 | + * lost some data, but we haven't lost any too critical data that would | |
| 40 | + * cause the decoder to desynchronize and output random garbage). | |
| 41 | + */ | |
| 38 | 42 | int sequence_ok; |
| 39 | 43 | int first_part_size; |
| 40 | 44 | uint16_t prev_seq; |
| 41 | 45 | int prev_pictureid; |
| 42 | 46 | int broken_frame; |
| 47 | + /* If sequence_dirty is set, we have lost some data (critical or | |
| 48 | + * non-critical) and decoding will have some sort of artefacts, and | |
| 49 | + * we thus should request a new keyframe. | |
| 50 | + */ | |
| 51 | + int sequence_dirty; | |
| 52 | + int got_keyframe; | |
| 43 | 53 | }; |
| 44 | 54 | |
| 45 | 55 | static void vp8_free_buffer(PayloadContext *vp8) |
| @@ -141,11 +151,15 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, · 95 unmodified lines | ||
| 141 | 151 | vp8_free_buffer(vp8); |
| 142 | 152 | // Keyframe, decoding ok again |
| 143 | 153 | vp8->sequence_ok = 1; |
| 154 | + vp8->sequence_dirty = 0; | |
| 155 | + vp8->got_keyframe = 1; | |
| 144 | 156 | } else { |
| 145 | 157 | int can_continue = vp8->data && !vp8->is_keyframe && |
| 146 | 158 | avio_tell(vp8->data) >= vp8->first_part_size; |
| 147 | 159 | if (!vp8->sequence_ok) |
| 148 | 160 | return AVERROR(EAGAIN); |
| 161 | + if (!vp8->got_keyframe) | |
| 162 | + return vp8_broken_sequence(ctx, vp8, "Keyframe missing\n"); | |
| 149 | 163 | if (pictureid >= 0) { |
| 150 | 164 | if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) { |
| 151 | 165 | return vp8_broken_sequence(ctx, vp8, |
| @@ -179,6 +193,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, · 27 unmodified lines | ||
| 179 | 193 | } |
| 180 | 194 | } |
| 181 | 195 | if (vp8->data) { |
| 196 | + vp8->sequence_dirty = 1; | |
| 182 | 197 | if (avio_tell(vp8->data) >= vp8->first_part_size) { |
| 183 | 198 | int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); |
| 184 | 199 | if (ret < 0) |
| @@ -220,6 +235,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, · 35 unmodified lines | ||
| 220 | 235 | "Missed part of a keyframe, sequence broken\n"); |
| 221 | 236 | } else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) { |
| 222 | 237 | vp8->broken_frame = 1; |
| 238 | + vp8->sequence_dirty = 1; | |
| 223 | 239 | } else { |
| 224 | 240 | return vp8_broken_sequence(ctx, vp8, |
| 225 | 241 | "Missed part of the first partition, sequence broken\n"); |
| @@ -253,7 +269,11 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, · 27 unmodified lines | ||
| 253 | 269 | |
| 254 | 270 | static PayloadContext *vp8_new_context(void) |
| 255 | 271 | { |
| 256 | − return av_mallocz(sizeof(PayloadContext)); | |
| 272 | + PayloadContext *vp8 = av_mallocz(sizeof(PayloadContext)); | |
| 273 | + if (!vp8) | |
| 274 | + return NULL; | |
| 275 | + vp8->sequence_ok = 1; | |
| 276 | + return vp8; | |
| 257 | 277 | } |
| 258 | 278 | |
| 259 | 279 | static void vp8_free_context(PayloadContext *vp8) |
| @@ -262,6 +282,11 @@ static void vp8_free_context(PayloadContext *vp8) · 2 unmodified lines | ||
| 262 | 282 | av_free(vp8); |
| 263 | 283 | } |
| 264 | 284 | |
| 285 | +static int vp8_need_keyframe(PayloadContext *vp8) | |
| 286 | +{ | |
| 287 | + return vp8->sequence_dirty || !vp8->sequence_ok; | |
| 288 | +} | |
| 289 | + | |
| 265 | 290 | RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { |
| 266 | 291 | .enc_name = "VP8", |
| 267 | 292 | .codec_type = AVMEDIA_TYPE_VIDEO, |
| @@ -269,4 +294,5 @@ RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { · 1 unmodified line | ||
| 269 | 294 | .alloc = vp8_new_context, |
| 270 | 295 | .free = vp8_free_context, |
| 271 | 296 | .parse_packet = vp8_handle_packet, |
| 297 | + .need_keyframe = vp8_need_keyframe, | |
| 272 | 298 | }; |
| @@ -336,6 +336,9 @@ static void dither_init(DitherDSPContext *ddsp, · 335 unmodified lines | ||
| 336 | 336 | ddsp->dither_int_to_float = dither_int_to_float_rectangular_c; |
| 337 | 337 | else |
| 338 | 338 | ddsp->dither_int_to_float = dither_int_to_float_triangular_c; |
| 339 | + | |
| 340 | + if (ARCH_X86) | |
| 341 | + ff_dither_init_x86(ddsp, method); | |
| 339 | 342 | } |
| 340 | 343 | |
| 341 | 344 | DitherContext *ff_dither_alloc(AVAudioResampleContext *avr, |
| @@ -85,4 +85,9 @@ void ff_dither_free(DitherContext **c); · 84 unmodified lines | ||
| 85 | 85 | */ |
| 86 | 86 | int ff_convert_dither(DitherContext *c, AudioData *dst, AudioData *src); |
| 87 | 87 | |
| 88 | +/* arch-specific initialization functions */ | |
| 89 | + | |
| 90 | +void ff_dither_init_x86(DitherDSPContext *ddsp, | |
| 91 | + enum AVResampleDitherMethod method); | |
| 92 | + | |
| 88 | 93 | #endif /* AVRESAMPLE_DITHER_H */ |
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | OBJS += x86/audio_convert_init.o \ |
| 2 | 2 | x86/audio_mix_init.o \ |
| 3 | + x86/dither_init.o \ | |
| 3 | 4 | |
| 4 | 5 | YASM-OBJS += x86/audio_convert.o \ |
| 5 | 6 | x86/audio_mix.o \ |
| 7 | + x86/dither.o \ | |
| @@ -0,0 +1,53 @@ | ||
| 1 | +;****************************************************************************** | |
| 2 | +;* x86 optimized dithering format conversion | |
| 3 | +;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com> | |
| 4 | +;* | |
| 5 | +;* This file is part of FFmpeg. | |
| 6 | +;* | |
| 7 | +;* FFmpeg is free software; you can redistribute it and/or | |
| 8 | +;* modify it under the terms of the GNU Lesser General Public | |
| 9 | +;* License as published by the Free Software Foundation; either | |
| 10 | +;* version 2.1 of the License, or (at your option) any later version. | |
| 11 | +;* | |
| 12 | +;* FFmpeg is distributed in the hope that it will be useful, | |
| 13 | +;* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 | +;* Lesser General Public License for more details. | |
| 16 | +;* | |
| 17 | +;* You should have received a copy of the GNU Lesser General Public | |
| 18 | +;* License along with FFmpeg; if not, write to the Free Software | |
| 19 | +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | +;****************************************************************************** | |
| 21 | + | |
| 22 | +%include "libavutil/x86/x86util.asm" | |
| 23 | + | |
| 24 | +SECTION_RODATA 32 | |
| 25 | + | |
| 26 | +pf_s16_scale: times 4 dd 32753.0 | |
| 27 | + | |
| 28 | +SECTION_TEXT | |
| 29 | + | |
| 30 | +;------------------------------------------------------------------------------ | |
| 31 | +; void ff_quantize(int16_t *dst, float *src, float *dither, int len); | |
| 32 | +;------------------------------------------------------------------------------ | |
| 33 | + | |
| 34 | +INIT_XMM sse2 | |
| 35 | +cglobal quantize, 4,4,3, dst, src, dither, len | |
| 36 | + lea lenq, [2*lend] | |
| 37 | + add dstq, lenq | |
| 38 | + lea srcq, [srcq+2*lenq] | |
| 39 | + lea ditherq, [ditherq+2*lenq] | |
| 40 | + neg lenq | |
| 41 | + mova m2, [pf_s16_scale] | |
| 42 | +.loop: | |
| 43 | + mulps m0, m2, [srcq+2*lenq] | |
| 44 | + mulps m1, m2, [srcq+2*lenq+mmsize] | |
| 45 | + addps m0, [ditherq+2*lenq] | |
| 46 | + addps m1, [ditherq+2*lenq+mmsize] | |
| 47 | + cvtps2dq m0, m0 | |
| 48 | + cvtps2dq m1, m1 | |
| 49 | + packssdw m0, m1 | |
| 50 | + mova [dstq+lenq], m0 | |
| 51 | + add lenq, mmsize | |
| 52 | + jl .loop | |
| 53 | + REP_RET | |
| @@ -0,0 +1,39 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com> | |
| 3 | + * | |
| 4 | + * This file is part of FFmpeg. | |
| 5 | + * | |
| 6 | + * FFmpeg is free software; you can redistribute it and/or | |
| 7 | + * modify it under the terms of the GNU Lesser General Public | |
| 8 | + * License as published by the Free Software Foundation; either | |
| 9 | + * version 2.1 of the License, or (at your option) any later version. | |
| 10 | + * | |
| 11 | + * FFmpeg is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | + * Lesser General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public | |
| 17 | + * License along with FFmpeg; if not, write to the Free Software | |
| 18 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#include "config.h" | |
| 22 | +#include "libavutil/cpu.h" | |
| 23 | +#include "libavutil/x86/cpu.h" | |
| 24 | +#include "libavresample/dither.h" | |
| 25 | + | |
| 26 | +extern void ff_quantize_sse2(int16_t *dst, const float *src, float *dither, | |
| 27 | + int len); | |
| 28 | + | |
| 29 | +av_cold void ff_dither_init_x86(DitherDSPContext *ddsp, | |
| 30 | + enum AVResampleDitherMethod method) | |
| 31 | +{ | |
| 32 | + int mm_flags = av_get_cpu_flags(); | |
| 33 | + | |
| 34 | + if (EXTERNAL_SSE2(mm_flags)) { | |
| 35 | + ddsp->quantize = ff_quantize_sse2; | |
| 36 | + ddsp->ptr_align = 16; | |
| 37 | + ddsp->samples_align = 8; | |
| 38 | + } | |
| 39 | +} | |