History

Merge commit '1fb8f6a44f06e48386450fe0363aefc02583d24a'

* 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

Michael Niedermayer committed 13 years ago

Commit 75afbe22 parents 34c1c08 1fb8f6a7 files · +140 −12Browse files

Unified · Split

7 files
  1. doc/APIchanges +11 −11
  2. libavformat/rtpdec_vp8.c +27 −1
  3. libavresample/dither.c +3 −0
  4. libavresample/dither.h +5 −0
  5. libavresample/x86/Makefile +2 −0
  6. libavresample/x86/dither.asm +53 −0
  7. libavresample/x86/dither_init.c +39 −0
doc/APIchanges+11−11
@@ -132,34 +132,34 @@ API changes, most recent first: · 131 unmodified lines
132132 2012-03-26 - a67d9cf - lavfi 2.66.100
133133 Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
134134
135−2013-xx-xx - xxxxxxx - lavr 1.1.0
135+2013-01-07 - 074a00d - lavr 1.1.0
136136 Add avresample_set_channel_mapping() for input channel reordering,
137137 duplication, and silencing.
138138
139−2012-xx-xx - xxxxxxx - lavu 52.2.1 - avstring.h
139+2012-12-29 - d8fd06c - lavu 52.2.1 - avstring.h
140140 Add av_basename() and av_dirname().
141141
142−2012-11-10 - 5980f5dd - lavu 52.2.0 - audioconvert.h
142+2012-11-11 - 5980f5d - lavu 52.2.0 - audioconvert.h
143143 Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated.
144144
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
147147
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
150150
151−2012-10-12 - d2fcb356 - lavu 51.44.0 - pixdesc.h
151+2012-10-12 - d2fcb35 - lavu 51.44.0 - pixdesc.h
152152 Add functions for accessing pixel format descriptors.
153153 Accessing the av_pix_fmt_descriptors array directly is now
154154 deprecated.
155155
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
157157 Add functions for allocating the opaque contexts for the algorithms,
158158
159−2012-10-10 - b522000e - lavf 54.18.0 - avio.h
159+2012-10-10 - b522000 - lavf 54.18.0 - avio.h
160160 Add avio_closep to complement avio_close.
161161
162−2012-10-06 - 78071a14 - lavu 51.42.0 - pixfmt.h
162+2012-10-08 - 78071a1 - lavu 51.42.0 - pixfmt.h
163163 Rename PixelFormat to AVPixelFormat and all PIX_FMT_* to AV_PIX_FMT_*.
164164 To provide backwards compatibility, PixelFormat is now #defined as
165165 AVPixelFormat.
libavformat/rtpdec_vp8.c+27−1
@@ -35,11 +35,21 @@ struct PayloadContext { · 34 unmodified lines
3535 AVIOContext *data;
3636 uint32_t timestamp;
3737 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+ */
3842 int sequence_ok;
3943 int first_part_size;
4044 uint16_t prev_seq;
4145 int prev_pictureid;
4246 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;
4353 };
4454
4555 static void vp8_free_buffer(PayloadContext *vp8)
@@ -141,11 +151,15 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, · 95 unmodified lines
141151 vp8_free_buffer(vp8);
142152 // Keyframe, decoding ok again
143153 vp8->sequence_ok = 1;
154+ vp8->sequence_dirty = 0;
155+ vp8->got_keyframe = 1;
144156 } else {
145157 int can_continue = vp8->data && !vp8->is_keyframe &&
146158 avio_tell(vp8->data) >= vp8->first_part_size;
147159 if (!vp8->sequence_ok)
148160 return AVERROR(EAGAIN);
161+ if (!vp8->got_keyframe)
162+ return vp8_broken_sequence(ctx, vp8, "Keyframe missing\n");
149163 if (pictureid >= 0) {
150164 if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) {
151165 return vp8_broken_sequence(ctx, vp8,
@@ -179,6 +193,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, · 27 unmodified lines
179193 }
180194 }
181195 if (vp8->data) {
196+ vp8->sequence_dirty = 1;
182197 if (avio_tell(vp8->data) >= vp8->first_part_size) {
183198 int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index);
184199 if (ret < 0)
@@ -220,6 +235,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, · 35 unmodified lines
220235 "Missed part of a keyframe, sequence broken\n");
221236 } else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) {
222237 vp8->broken_frame = 1;
238+ vp8->sequence_dirty = 1;
223239 } else {
224240 return vp8_broken_sequence(ctx, vp8,
225241 "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
253269
254270 static PayloadContext *vp8_new_context(void)
255271 {
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;
257277 }
258278
259279 static void vp8_free_context(PayloadContext *vp8)
@@ -262,6 +282,11 @@ static void vp8_free_context(PayloadContext *vp8) · 2 unmodified lines
262282 av_free(vp8);
263283 }
264284
285+static int vp8_need_keyframe(PayloadContext *vp8)
286+{
287+ return vp8->sequence_dirty || !vp8->sequence_ok;
288+}
289+
265290 RTPDynamicProtocolHandler ff_vp8_dynamic_handler = {
266291 .enc_name = "VP8",
267292 .codec_type = AVMEDIA_TYPE_VIDEO,
@@ -269,4 +294,5 @@ RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { · 1 unmodified line
269294 .alloc = vp8_new_context,
270295 .free = vp8_free_context,
271296 .parse_packet = vp8_handle_packet,
297+ .need_keyframe = vp8_need_keyframe,
272298 };
libavresample/dither.c+3−0
@@ -336,6 +336,9 @@ static void dither_init(DitherDSPContext *ddsp, · 335 unmodified lines
336336 ddsp->dither_int_to_float = dither_int_to_float_rectangular_c;
337337 else
338338 ddsp->dither_int_to_float = dither_int_to_float_triangular_c;
339+
340+ if (ARCH_X86)
341+ ff_dither_init_x86(ddsp, method);
339342 }
340343
341344 DitherContext *ff_dither_alloc(AVAudioResampleContext *avr,
libavresample/dither.h+5−0
@@ -85,4 +85,9 @@ void ff_dither_free(DitherContext **c); · 84 unmodified lines
8585 */
8686 int ff_convert_dither(DitherContext *c, AudioData *dst, AudioData *src);
8787
88+/* arch-specific initialization functions */
89+
90+void ff_dither_init_x86(DitherDSPContext *ddsp,
91+ enum AVResampleDitherMethod method);
92+
8893 #endif /* AVRESAMPLE_DITHER_H */
libavresample/x86/Makefile+2−0
@@ -1,5 +1,7 @@
11 OBJS += x86/audio_convert_init.o \
22 x86/audio_mix_init.o \
3+ x86/dither_init.o \
34
45 YASM-OBJS += x86/audio_convert.o \
56 x86/audio_mix.o \
7+ x86/dither.o \
libavresample/x86/dither.asm+53−0
@@ -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
libavresample/x86/dither_init.c+39−0
@@ -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+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t