Commit Graph

254 Commits

Author SHA1 Message Date
Derek Buitenhuis
278dcec28d Merge commit 'a6e27f7add2698fdd89911632b570c3d0c3f2aaa'
* commit 'a6e27f7add2698fdd89911632b570c3d0c3f2aaa':
  h264: factor out parsing the reference count into a separate file

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-17 15:16:38 +01:00
Derek Buitenhuis
7ab2c036b9 Merge commit 'e9f884416c76558098fc1f63825b293956e8483c'
* commit 'e9f884416c76558098fc1f63825b293956e8483c':
  h264: move reading direct_spatial_mv_pred out of ff_set_ref_count()

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-17 14:38:14 +01:00
Derek Buitenhuis
297e2768da Merge commit 'ad9d3384de08f02967d6eb11196ee8c78e8b2dba'
* commit 'ad9d3384de08f02967d6eb11196ee8c78e8b2dba':
  svq3: move the dequant buffer to SVQ3Context

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-03 10:15:22 +01:00
Derek Buitenhuis
ee38234c43 Merge commit 'e481458bc308ee838deaeacac51929514762e7a7'
* commit 'e481458bc308ee838deaeacac51929514762e7a7':
  h264: factor out pred weight table parsing into a separate file

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-26 15:04:29 +01:00
Derek Buitenhuis
9809371aa5 Merge commit 'a7da517f6a5c472f46f67dd33bb6b95ccc919923'
* commit 'a7da517f6a5c472f46f67dd33bb6b95ccc919923':
  h264data: Move all data tables from a header to a .c file

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-24 11:54:53 +01:00
Derek Buitenhuis
a5a6621616 Merge commit 'f4d581cda3897f66c1dda7586b93f86a591dbbef'
* commit 'f4d581cda3897f66c1dda7586b93f86a591dbbef':
  lavc: Deduplicate zigzag_scan table

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-24 11:47:39 +01:00
Anton Khirnov
a6e27f7add h264: factor out parsing the reference count into a separate file
This will allow decoupling the parser from the decoder.
2016-04-24 10:06:23 +02:00
Anton Khirnov
e9f884416c h264: move reading direct_spatial_mv_pred out of ff_set_ref_count()
It has nothing to do with the reference count and so does not belong in
this function.
2016-04-24 10:06:23 +02:00
Diego Biurrun
061dc20351 h264: Add missing ff_ prefix to internally visible h264_init_dequant_tables() 2016-03-30 17:19:13 +02:00
Anton Khirnov
ad9d3384de svq3: move the dequant buffer to SVQ3Context
Remove now unnecesary call to ff_h264_alloc_tables()
2016-03-28 09:56:09 +02:00
Anton Khirnov
e481458bc3 h264: factor out pred weight table parsing into a separate file
This will allow decoupling the parser from the decoder.
2016-03-28 09:48:31 +02:00
Michael Niedermayer
c50be7a52b avcodec/h264_slice: Check PPS more extensively when its not copied
Fixes Ticket5371
Fixes null pointer dereference

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-27 05:03:44 +02:00
Diego Biurrun
a7da517f6a h264data: Move all data tables from a header to a .c file 2016-03-25 15:56:14 +01:00
Diego Biurrun
f4d581cda3 lavc: Deduplicate zigzag_scan table 2016-03-25 15:23:56 +01:00
Mark Thompson
d264c720f7 lavu: deprecate AV_PIX_FMT_VAAPI_*, replace with AV_PIX_FMT_VAAPI
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-03-19 15:40:22 +01:00
Derek Buitenhuis
1a12eb4a73 Merge commit '29c2d06d67724e994980045afa055c6c34611b30'
* commit '29c2d06d67724e994980045afa055c6c34611b30':
  cosmetics: Drop empty comment lines

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-24 17:31:44 +00:00
Diego Biurrun
29c2d06d67 cosmetics: Drop empty comment lines 2016-02-18 15:35:30 +01:00
Michael Niedermayer
6973846618 avcodec/h264_slice: Fix dequant table init with field pictures
Fixes regression of Ticket4389

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-12 04:37:35 +01:00
Michael Niedermayer
873158fd76 avcodec/h264_slice: assert relation between current_slice ans slice_ctx
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-12 04:37:35 +01:00
Michael Niedermayer
6c6f2e49e4 avcodec/h264_slice: remove duplicate unconditional picture_structure setting code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-12 04:37:35 +01:00
Derek Buitenhuis
21f9468402 avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPAT
Libav, for some reason, merged this as a public API function. This will
aid in future merges.

A define is left for backwards compat, just in case some person
used it, since it is in a public header.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-01-27 16:36:46 +00:00
Michael Niedermayer
7cc01c2572 avcodec/h264_slice: Fix integer overflow in implicit weight computation
Fixes mozilla bug 1230423

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-05 01:12:42 +01:00
Mark Harris
c51c08e0e7 avcodec: Use get_ue_golomb_long() when needed
get_ue_golomb() cannot decode values larger than 8190 (the maximum
value that can be golomb encoded in 25 bits) and produces the error
"Invalid UE golomb code" if a larger value is encountered.  Use
get_ue_golomb_long() instead (which supports 63 bits, up to 4294967294)
when valid h264/hevc values can exceed 8190.

This updates decoding of the following values:   (maximum)
  first_mb_in_slice                                36863* for level 5.2
  abs_diff_pic_num_minus1                         131071
  difference_of_pic_nums_minus1                   131071
  idr_pic_id                                       65535
  recovery_frame_cnt                               65535
  frame_packing_arrangement_id                4294967294
  frame_packing_arrangement_repetition_period      16384
  display_orientation_repetition_period            16384

An alternative would be to modify get_ue_golomb() to handle encoded
values of up to 49 bits as was done for get_se_golomb() in a92816c.
In that case get_ue_golomb() could continue to be used for all of
these except frame_packing_arrangement_id.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-29 13:11:51 +01:00
Michael Niedermayer
ef8f6464a5 avcodec/h264_slice: Simplify ref2frm indexing
This also suppresses a ubsan warning
Fixes Mozilla bug 1230247

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-18 00:54:28 +01:00
Hendrik Leppkes
c6f1f334cb Merge commit '792b9c9dfcf44b657d7854368d975b5ca3bc22ca'
* commit '792b9c9dfcf44b657d7854368d975b5ca3bc22ca':
  h264: set frame_num in start_frame(), not decode_slice_header()

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-12-17 12:59:25 +01:00
Hendrik Leppkes
bc66451e5e Merge commit '741b494fa8cd28a7d096349bac183893c236e3f9'
* commit '741b494fa8cd28a7d096349bac183893c236e3f9':
  h264: eliminate default_ref_list

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-12-17 12:45:28 +01:00
Anton Khirnov
f1ccd07680 h264: do not call frame_start() for missing frames
We do not need to do a full setup like for a real frame, just allocate a
buffer and set cur_pic(_ptr).
2015-12-07 11:42:26 +01:00
Anton Khirnov
792b9c9dfc h264: set frame_num in start_frame(), not decode_slice_header()
That is a more appropriate place for it, since it is not allowed to
change between slices.
2015-12-06 09:43:45 +01:00
Anton Khirnov
741b494fa8 h264: eliminate default_ref_list
According to the spec, the reference list for a slice should be
constructed by first generating an initial (what we now call "default")
reference list and then optionally applying modifications to it.

Our code has an optimization where the initial reference list is
constructed for the first inter slice and then rebuilt for other slices
if needed. This, however, adds complexity to the code, requires an extra
2.5kB array in the codec context and there is no reason to think that it
has any positive effect on performance. Therefore, simplify the code by
generating the reference list from scratch for each slice.
2015-12-06 09:42:39 +01:00
Michael Niedermayer
8000d484b8 avcodec/cabac: Check initial cabac decoder state
Fixes integer overflows
Fixes: 1430e9c43fae47a24c179c7c54f94918/signal_sigsegv_421427_2340_591e9810c7b09efe501ad84638c9e9f8.264

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Found-by: xiedingbao (Ticket4727)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-27 13:52:47 +01:00
Michael Niedermayer
4ea4d2f438 avcodec/h264_slice: Limit max_contexts when slice_context_count is initialized
Fixes out of array access
Fixes: 1430e9c43fae47a24c179c7c54f94918/signal_sigsegv_421427_2049_f2192b6829ab6e0eefcb035329c03c60.264

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-24 22:17:36 +01:00
Michael Niedermayer
6f37226b68 avcodec/h264_slice: Clear top_borders on allocation
In case of bitstream errors the deblock filter and slices can access uninitialized
top_borders from previous slices which did not fill them as they stoped halfway due
to error or where entirely missing.

This also makes code using these tables deterministic in case of missing or damaged
slices

Found-by: Tyson Smith
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-18 22:18:01 +01:00
Michael Niedermayer
507b01f899 avcodec/h264_slice: Disable slice threads if there are multiple access units in a packet
Fixes null pointer dereference
Fixes Ticket4977

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-31 22:56:48 +01:00
Andreas Cadhalpun
a4680e7170 avcodec: rename avpriv_color_frame to ff_color_frame
It is only used inside libavcodec.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-10-22 00:38:50 +02:00
wm4
17fe18d21a Revert "avcodec/h264: remove redundant and bogus get_format call"
This reverts commit be583c6fd3.

This was not approved, and was accidentally pushed. I'm very sorry.
2015-10-15 20:19:55 +02:00
wm4
be583c6fd3 avcodec/h264: remove redundant and bogus get_format call
The AVCodecContext.get_format callback is not only used for pixel format
negotiation with the API user, but also for hwaccel init. For the
latter, it's required that some codec parameters, in particular the
codec profile, are set when the callback is invoked.

This patch removes a get_format invocation where this is not guaranteed.
The codec parameters, including the profile, are really set further
below. (The same code path that sets the profile also calls get_format
properly too.)

This just happened to work by coincidence in most cases. For example, if
the API user just copied or reused the AVStream's AVCodecContext when
decoding, the profile would be set properly. But in some cases it
fails., such as with the sample WolfensteinTwitch.mp4 on the samples
server.

Remove the redundant get_format call. Apparently it serves no purpose
anymore, although it is possible that this was different at the time it
was added in commit ffd77f94a2.

This fixes hwaccel usage for API users which do not set the profile
when setting up the AVCodecContext (which is allowed).
2015-10-15 20:16:13 +02:00
Michael Niedermayer
1376084dcb avcodec/h264_slice: replace assert by normal error check
Fixes assertion failure
Fixes: c6075771557e4f3b7b74e63d2d24fb01/signal_sigabrt_7ffff6ac8cc9_133_cov_2853689970_CREDITS.FST

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-02 01:22:45 +02:00
Gwenole Beauchesne
9f8e57efe4 vaapi: define a unique pixel format for VA-API (AV_PIX_FMT_VAAPI).
Deprecate older VA pixel formats (MOCO, IDCT) as it is now very unlikely
to ever be useful in the future. Only keep plain AV_PIX_FMT_VAAPI format
that is aliased to the older VLD variant.

This is an API change.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2015-08-19 14:03:24 +02:00
Ronald S. Bultje
030b5a4f77 lavc: put remaining bits of vdpau-in-decoder under FF_API_CAP_VDPAU. 2015-08-18 15:57:19 -04:00
wm4
94c0df79c7 lavc: propagate hwaccel errors
At least the new videotoolbox decoder does not actually set a frame if
end_frame fails. This causes the API to return success and signals that
a picture was decoded, even though AVFrame->data[0] is NULL.

Fix this by propagating end_frame errors.
2015-08-06 11:05:02 +02:00
Sebastien Zwickert
11d923d414 avcodec: add new Videotoolbox hwaccel. 2015-08-03 10:12:10 +02:00
Michael Niedermayer
c3fdf536f6 avcodec/h264_slice: Also check sei_recovery_frame_cnt for skip_frame nokey
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-28 13:27:16 +02:00
Michael Niedermayer
accc91642b avcodec/h264_slice: do not skip 2nd field if first was not skipped
Found-by: John Högberg <john.hogberg@ericsson.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-28 11:40:57 +02:00
Michael Niedermayer
444e9874a7 Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'
* commit 'def97856de6021965db86c25a732d78689bd6bb0':
  lavc: AV-prefix all codec capabilities

Conflicts:
	cmdutils.c
	ffmpeg.c
	ffplay.c
	libavcodec/8svx.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.c
	libavcodec/adpcm.c
	libavcodec/alac.c
	libavcodec/atrac3plusdec.c
	libavcodec/bink.c
	libavcodec/dnxhddec.c
	libavcodec/dvdec.c
	libavcodec/dvenc.c
	libavcodec/ffv1dec.c
	libavcodec/ffv1enc.c
	libavcodec/fic.c
	libavcodec/flacdec.c
	libavcodec/flacenc.c
	libavcodec/flvdec.c
	libavcodec/fraps.c
	libavcodec/frwu.c
	libavcodec/gifdec.c
	libavcodec/h261dec.c
	libavcodec/hevc.c
	libavcodec/iff.c
	libavcodec/imc.c
	libavcodec/libopenjpegdec.c
	libavcodec/libvo-aacenc.c
	libavcodec/libvorbisenc.c
	libavcodec/libvpxdec.c
	libavcodec/libvpxenc.c
	libavcodec/libx264.c
	libavcodec/mjpegbdec.c
	libavcodec/mjpegdec.c
	libavcodec/mpegaudiodec_float.c
	libavcodec/msmpeg4dec.c
	libavcodec/mxpegdec.c
	libavcodec/nvenc_h264.c
	libavcodec/nvenc_hevc.c
	libavcodec/pngdec.c
	libavcodec/qpeg.c
	libavcodec/ra288.c
	libavcodec/rv10.c
	libavcodec/s302m.c
	libavcodec/sp5xdec.c
	libavcodec/takdec.c
	libavcodec/tiff.c
	libavcodec/tta.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/vp6.c
	libavcodec/vp9.c
	libavcodec/wavpack.c
	libavcodec/yop.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 22:50:18 +02:00
Michael Niedermayer
94d68a41fa Merge commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615'
* commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615':
  lavc: AV-prefix all codec flags

Conflicts:
	doc/examples/muxing.c
	ffmpeg.c
	ffmpeg_opt.c
	ffplay.c
	libavcodec/aacdec.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.c
	libavcodec/ac3enc_float.c
	libavcodec/atrac1.c
	libavcodec/atrac3.c
	libavcodec/atrac3plusdec.c
	libavcodec/dcadec.c
	libavcodec/ffv1enc.c
	libavcodec/h264.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_mb.c
	libavcodec/imc.c
	libavcodec/libmp3lame.c
	libavcodec/libtheoraenc.c
	libavcodec/libtwolame.c
	libavcodec/libvpxenc.c
	libavcodec/libxavs.c
	libavcodec/libxvid.c
	libavcodec/mpeg12dec.c
	libavcodec/mpeg12enc.c
	libavcodec/mpegaudiodec_template.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/mpegvideo_motion.c
	libavcodec/nellymoserdec.c
	libavcodec/nellymoserenc.c
	libavcodec/nvenc.c
	libavcodec/on2avc.c
	libavcodec/options_table.h
	libavcodec/opus_celt.c
	libavcodec/pngenc.c
	libavcodec/ra288.c
	libavcodec/ratecontrol.c
	libavcodec/twinvq.c
	libavcodec/vc1_block.c
	libavcodec/vc1_loopfilter.c
	libavcodec/vc1_mc.c
	libavcodec/vc1dec.c
	libavcodec/vorbisdec.c
	libavcodec/vp3.c
	libavcodec/wma.c
	libavcodec/wmaprodec.c
	libavcodec/x86/hpeldsp_init.c
	libavcodec/x86/me_cmp_init.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 22:10:35 +02:00
Vittorio Giovara
7c6eb0a1b7 lavc: AV-prefix all codec flags
Convert doxygen to multiline and express bitfields more simply.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:58 +01:00
Michael Niedermayer
3c63d06d81 avcodec/h264_slice: Fix container cropping
Fixes out of array read
Fixes: asan_heap-oob_394322e_138_cov_4265020547_CVPCMNL1_SVA_C.264

Found-by: Samuel Groß, Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-08 17:50:05 +02:00
Michael Niedermayer
2e9dcb82e5 Merge commit '3e3056f2a020dd77efdf379dbd4c06a65b4a499a'
* commit '3e3056f2a020dd77efdf379dbd4c06a65b4a499a':
  h264: Allow stream and container cropping at the same time

Conflicts:
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-30 21:11:49 +02:00
Vittorio Giovara
3e3056f2a0 h264: Allow stream and container cropping at the same time
The container cropping is applied only when difference is within 16
pixels, and the smallest value between the two is chosen.

Bug-Id: 383
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-06-30 15:34:37 +02:00
Michael Niedermayer
330863c9f1 avcodec/h264_slice: Use w/h from the AVFrame instead of mb_w/h
Fixes out of array access
Fixes: asan_heap-oob_4d5bb0_682_cov_3124593265_Fraunhofer__a_driving_force_in_innovation__small.mp4

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-30 19:38:44 +02:00