Commit Graph

226 Commits

Author SHA1 Message Date
Anton Khirnov 759001c534 lavc decoders: work with refcounted frames. 2013-03-08 07:38:30 +01:00
Diego Biurrun 5f401b7b71 Add missing error_resilience includes to files that use ER 2013-03-07 15:04:49 +01:00
Diego Biurrun 94ee7da08d Remove pointless av_cold attributes in header files
The init functions marked as av_cold have to be executed in any case,
so there is no gain from trying to mark paths leading to such functions
as unlikely.
2013-02-23 20:13:47 +01:00
Ronald S. Bultje fae6fd5b87 h264/svq3: Stop using draw_edges
Instead, only extend edges on-demand when the motion vector actually
crosses the visible decoded area using ff_emulated_edge_mc(). This
changes decoding time for cathedral from 8.722sec to 8.706sec, i.e.
0.2% faster overall. More generally (VP8 uses this also), low-motion
content gets significant speed improvements, whereas high-motion content
tends to decode in approximately the same time.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-02-19 22:34:33 +02:00
Ronald S. Bultje 7ebfb466ae h264: Don't store intra pcm samples in h->mb
Instead, keep them in the bitstream buffer until we read them verbatim,
this saves a memcpy() and a subsequent clearing of the target buffer.
decode_cabac+decode_mb for a sample file (CAPM3_Sony_D.jsv) goes from
6121.4 to 6095.5 cycles, i.e. 26 cycles faster.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-02-19 22:34:14 +02:00
Anton Khirnov 2c54155407 h264: deMpegEncContextize
Most of the changes are just trivial are just trivial replacements of
fields from MpegEncContext with equivalent fields in H264Context.
Everything in h264* other than h264.c are those trivial changes.

The nontrivial parts are:
1) extracting a simplified version of the frame management code from
   mpegvideo.c. We don't need last/next_picture anymore, since h264 uses
   its own more complex system already and those were set only to appease
   the mpegvideo parts.
2) some tables that need to be allocated/freed in appropriate places.
3) hwaccels -- mostly trivial replacements.
   for dxva, the draw_horiz_band() call is moved from
   ff_dxva2_common_end_frame() to per-codec end_frame() callbacks,
   because it's now different for h264 and MpegEncContext-based
   decoders.
4) svq3 -- it does not use h264 complex reference system, so I just
   added some very simplistic frame management instead and dropped the
   use of ff_h264_frame_start(). Because of this I also had to move some
   initialization code to svq3.

Additional fixes for chroma format and bit depth changes by
Janne Grunau <janne-libav@jannau.net>

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2013-02-15 16:35:16 +01:00
Anton Khirnov 9782c778a2 h264: remove silly macros
They serve no useful purpose and wreak all kind of havoc when h264.h is
included elsewhere.
2013-02-06 21:45:02 +01:00
Diego Biurrun 79dad2a932 dsputil: Separate h264chroma 2013-02-06 11:30:53 +01:00
Mans Rullgard e9d817351b dsputil: Separate h264 qpel
The sh4 optimizations are removed, because the code is
100% identical to the C code, so it is unlikely to
provide any real practical benefit.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-01-24 10:44:43 +01:00
Diego Biurrun 88bd7fdc82 Drop DCTELEM typedef
It does not help as an abstraction and adds dsputil dependencies.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2013-01-22 18:32:56 -08:00
Anton Khirnov 940b8b5861 h264: avoid pointless copying of ref lists
ref_list is constructed from other fields per slice when needed, so do
not copy it for both frame and slice threading.
default_ref_list is constructed per frame and still needs to be copied
to per-slice contexts for slice threading, but a copy is not needed for
frame threading.
2013-01-18 07:56:05 +01:00
Anton Khirnov ea382767ad h264: fix ff_generate_sliding_window_mmcos() prototype.
It's been returning an error value since
bad446e251

Also check for the errors it returns.
2013-01-14 21:36:08 +01:00
Ronald S. Bultje bad446e251 h264: don't clobber mmco opcode tables for non-first slice headers.
Clobbering these tables will temporarily clobber the template used
as a basis for other threads to start decoding from. If the other
decoding thread updates from the template right at that moment,
subsequent threads will get invalid (or, usually, none at all) mmco
tables. This leads to invalid reference lists and subsequent decode
failures.

Therefore, instead, decode the mmco tables only for the first slice in
a field or frame. For other slices, decode the bits and ensure they
are identical to the mmco tables in the first slice, but don't ever
clobber the context state. This prevents other threads from using a
clobbered/invalid template as starting point for decoding, and thus
fixes decoding in these cases.

This fixes occasional (~1%) failures of h264-conformance-mr1_bt_a with
frame-multithreading enabled.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-01-14 19:20:47 +01:00
Janne Grunau 9e696d2e5f h264: support frame parameter changes during frame-mt
Fixes CVE-2012-2782.
2012-12-18 19:55:10 +01:00
Janne Grunau 73ad2c2fa7 h264: increase dist_scale_factor for up to 32 references
Compute dist_scale_factor_field only for MBAFF since that is the only
case in which it is used.
2012-12-18 19:36:58 +01:00
Janne Grunau 61c6eef545 h264: prevent decoding of slice NALs in extradata
It is not posible to call get_buffer during frame-mt codec
initialization. Libavformat might pass huge amounts of data as
extradata after parsing broken files. The 'extradata' for the fuzzed
sample sample_varPAR_s5374_r001-02.avi is 2.8M large and contains
multiple slices.
2012-12-18 11:01:14 +01:00
Janne Grunau 6a27ae28f9 mpegvideo: treat delayed pictures as used
This requires to move the avcodec_default_free_buffers() call to
ff_MPV_common_end() since otherwise delayed pictures would get freed
during a size change.
2012-12-13 21:02:42 +01:00
Janne Grunau 072be3e896 h264: set parameters from SPS whenever it changes
Fixes a crash in the fuzzed sample sample_varPAR.avi_s26638 with
alternating bit depths.
2012-12-13 21:02:42 +01:00
Janne Grunau a394959bbe h264: add a pointer for weighted prediction temporary buffer
Reusing MpegEncContext's obmc_scratchpad for this becomes a mess with
adaptive frame-mt.
2012-12-07 11:43:28 +01:00
Diego Biurrun be545b8a34 h264: K&R formatting cosmetics for header files (part I/II) 2012-05-10 13:02:47 +02:00
Diego Biurrun 0becb07842 h264: Factorize declaration of mb_sizes array. 2012-04-05 17:17:22 +02:00
Diego Biurrun 9ad80ef3db h264: Make ff_h264_decode_end() static, it is not used externally.
Also drop the now unnecessary ff_ prefix from its name.
2012-03-30 17:46:52 +02:00
Ronald S. Bultje 45b7bd7c53 h264: disallow constrained intra prediction modes for luma.
Conversion of the luma intra prediction mode to one of the constrained
("alzheimer") ones can happen by crafting special bitstreams, causing
a crash because we'll call a NULL function pointer for 16x16 block intra
prediction, since constrained intra prediction functions are only
implemented for chroma (8x8 blocks).

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
2012-02-09 22:57:01 -08:00
Janne Grunau 358ea75e9e Revert "h264: skip start code search if the size of the nal unit is known"
This reverts commit 87eebb3454.
2011-12-19 03:24:32 +01:00
Janne Grunau 87eebb3454 h264: skip start code search if the size of the nal unit is known
Start code emulation prevention is only required in Annex B bytestream
packed NAL units. For other coding formats the size is already known.
Looking for a start code prefix can result in false positives like in
http://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4
which has a false positive in the SPS.
2011-12-18 23:52:53 +01:00
Luca Barbato 5bf2ac2b37 error_resilience: use the ER_ namespace
Add the namespace to {AC_,DC_,MV_}{END,ERROR} macros

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2011-12-13 16:20:58 +01:00
Diego Biurrun 58c42af722 doxygen: misc consistency, spelling and wording fixes 2011-12-12 23:06:23 +01:00
Ronald S. Bultje adedd840e2 h264: fix frame reordering code.
Fixes fate-h264-conformance-{mr2_tandberg_e,mr3_tandberg_b} without
requiring -strict 1.
2011-12-03 08:24:27 -08:00
Ronald S. Bultje ea2bb12e3e h264: improve calculation of codec delay.
Fixes the following conformance suite samples:
HCBP1_HHI_A.264, HCBP2_HHI_A.264, HCMP1_HHI_A.264 (main)
HCHP1_HHI_B.264, HCHP2_HHI_A.264, HCHP3_HHI_A.264 (frext)
2011-11-05 06:58:52 -07:00
Baptiste Coudurier 76741b0e56 h264: 4:2:2 intra decoding support
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-10-21 01:00:41 -07:00
Diego Biurrun 806212498a h264: move fill_decode_neighbors()/fill_decode_caches() to h264_mvpred.h
This fixes a bunch of unused function warnings.
2011-07-14 04:09:49 +02:00
Diego Biurrun 028216b2c2 h264: move decode_mb_skip() from h264.h to h.264_mvpred.h
This resolves a circular dependency between the headers.
2011-07-12 20:36:50 +02:00
Ronald S. Bultje c90a2538a0 h264: move h264_mvpred.h include.
Fixes the following compile error with darwin/gcc-4.2.1:
In file included from libavcodec/error_resilience.c:33:
libavcodec/h264.h: In function ‘decode_mb_skip’:
libavcodec/h264.h:773: error: ‘always_inline’ function could not be inlined in call to ‘pred_pskip_motion’: the function body must appear before caller
libavcodec/h264.h:1334: error: called from here
2011-07-12 08:15:55 -07:00
Diego Biurrun 657ccb5ac7 Eliminate FF_COMMON_FRAME macro.
FF_COMMON_FRAME holds the contents of the AVFrame structure and is also copied
to struct Picture.  Replace by an embedded AVFrame structure in struct Picture.
2011-07-11 00:19:00 +02:00
Jason Garrett-Glaser ef0c594801 H.264: merge fill_rectangle into P-SKIP MV prediction, to match B-SKIP 2011-07-08 16:12:12 -07:00
Jason Garrett-Glaser 5136ba7c69 H.264: faster P-SKIP decoding
Inline the relevant parts of fill_decode_caches into P-SKIP mv prediction to
avoid calling the whole thing.
2011-07-08 16:11:15 -07:00
Jason Garrett-Glaser bbdd52ed34 H.264: av_always_inline some more functions
These weren't getting inlined all the time in all gcc versions.
2011-07-08 16:09:35 -07:00
Jason Garrett-Glaser 556f8a066c H.264: template left MB handling
Faster H.264 decoding with ALLOW_INTERLACE off.
2011-07-03 15:06:00 -07:00
Jason Garrett-Glaser ca80f11ec3 H.264: faster fill_decode_caches
Aliasing avoidance and general cleanup.
2011-07-03 15:05:57 -07:00
Jason Garrett-Glaser 3b7ebeb4d5 H.264: faster write_back_*
Avoid aliasing, unroll loops, and inline more functions.
2011-07-03 15:05:55 -07:00
Reinhard Tartler 21a19b7912 doxygen: Prefer member groups over grouping into modules
Before this, almost all module groups have been used for grouping functions
and fields in structures semantically. This causes them to not appear
properly in the file documentation and needlessly clutters up the "Modules"
index.

Additionally, this commit streamlines some spelling and appearances.
2011-07-02 13:52:29 +02:00
Jason Garrett-Glaser c90b94424c 4:4:4 H.264 decoding support
Note: this is 4:4:4 from the 2007 spec revision, not the previous (now deprecated) 4:4:4 mode in H.264.
2011-06-13 21:16:30 -07:00
Jason Garrett-Glaser 504811baea Roll back 4:4:4 H.264 for now
Needs some ARM/PPC asm modifications.
2011-06-13 13:38:46 -07:00
Jason Garrett-Glaser c9c493872c 4:4:4 H.264 decoding support
Note: this is 4:4:4 from the 2007 spec revision, not the previous (now deprecated) 4:4:4 mode in H.264.
2011-06-13 12:21:39 -07:00
Baptiste Coudurier 8dfc6d1f7c svq3: Move svq3-specific fields to their own context.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2011-06-03 13:55:54 +02:00
Alexander Strange 6a9c859444 H264/MPEG frame-level multi-threading.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-06-02 10:16:20 -07:00
Oskar Arvidsson fcc0224e4f Add support for higher QP values in h264.
In high bit depth, the QP values may now be up to (51 + 6*(bit_depth-8)).

Preparatory patch for high bit depth h264 decoding support.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-05-10 07:24:35 -04:00
Oskar Arvidsson 6e3ef511d7 Add the notion of pixel size in h264 related functions.
In high bit depth the pixels will not be stored in uint8_t like in the
normal case, but in uint16_t. The pixel size is thus 1 in normal bit
depth and 2 in high bit depth.

Preparatory patch for high bit depth h264 decoding support.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-05-10 07:24:33 -04:00
Stefano Sabatini 975a1447f7 Replace deprecated FF_*_TYPE symbols with AV_PICTURE_TYPE_*.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2011-05-02 12:18:44 +02:00
Diego Biurrun e6ff064845 Eliminate pointless '#if 1' statements without matching '#else'. 2011-04-26 20:18:27 +02:00