Commit Graph

527 Commits

Author SHA1 Message Date
Michael Niedermayer 4da2ac5c7a avcodec/h264: Fix regression caused by removial of default_ref_list
This fixes a regression of the sample from Ticket 2371

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-04 02:30:48 +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 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
Hendrik Leppkes 15db457ea8 Merge commit 'd15368ee3926152a3a301c13cc638fbf7a062ddf'
* commit 'd15368ee3926152a3a301c13cc638fbf7a062ddf':
  h264: Run VLC init under pthread_once

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-14 23:06:06 +02:00
Derek Buitenhuis d15368ee39 h264: Run VLC init under pthread_once
This makes the h.264 decoder threadsafe to initialize.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-10-14 14:35:34 +02:00
wm4 069190f707 avcodec/h264: keep SPS and PPS bitstream data
We assume an upper bound of 4096 bytes for each raw SPS/PPS. It's hard
to determine an exact maximum size, but this value was was considered
high enough and safe.

Needed for the following VideotoolBox commit.
2015-10-02 19:08:54 +02:00
Hendrik Leppkes b1d547fe02 Merge commit '0f562f5b833d603e04123d198c59f8b2b5eb43e4'
* commit '0f562f5b833d603e04123d198c59f8b2b5eb43e4':
  h264: Do not print an error when the buffer has to be refilled

Conflicts:
	libavcodec/h264.c

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-08-10 11:11:42 +02:00
Hendrik Leppkes 8015150f43 Merge commit '9469370fb32679352e66826daf77bdd2e6f067b5'
* commit '9469370fb32679352e66826daf77bdd2e6f067b5':
  h264: Use AVERROR return codes instead of -1

Only partially merged, as the first hunk is not correct and would result
in endless log spam.

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-08-07 09:54:12 +02:00
Michael Niedermayer 441d5a7084 Merge commit 'b0017579b6e8de3d0d13dcfe0a4dd848dc6baa37'
* commit 'b0017579b6e8de3d0d13dcfe0a4dd848dc6baa37':
  h264: Add support for Closed Caption export

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_sei.c

See: 8234f0e3b4
Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-17 14:13:19 +02:00
Kieran Kunhya b0017579b6 h264: Add support for Closed Caption export
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-17 01:44:22 +01:00
Kieran Kunhya 8234f0e3b4 avcodec: Add support for Closed Caption export in h264
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-06 15:25:22 +02:00
Nicolas DEROUINEAU 04a68f4348 avcodec/h264: Greenmetadata SEI parsing
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-30 23:20:36 +02:00
Michael Niedermayer 7e9c7b623f Merge commit '271ce76d317c5432e151216cf23f12b77ed6cb7e'
* commit '271ce76d317c5432e151216cf23f12b77ed6cb7e':
  h264: Parse registered data SEI message and AFD value

Conflicts:
	libavcodec/h264.c
	libavcodec/h264.h
	libavcodec/h264_sei.c
	libavcodec/version.h

See: d6e9566949
See: 22291c372f
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-30 22:54:33 +02:00
Vittorio Giovara 271ce76d31 h264: Parse registered data SEI message and AFD value
Partially based on code by Marton Balint and Kieran Kunhya.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-06-30 15:34:38 +02:00
Michael Niedermayer bd5c6a519e Merge commit '5ec0bdf2c524224f30ba4786f47324970aed4aaa'
* commit '5ec0bdf2c524224f30ba4786f47324970aed4aaa':
  h264: do not update the context fields copied between threads after finish_setup()

Conflicts:
	libavcodec/h264.h
	libavcodec/h264_slice.c

See: f111831ed6 and others
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-27 22:15:01 +02:00
Michael Niedermayer f620315fa5 Merge commit 'e49e0f58e273237f83b4486f3536931ed1943d18'
* commit 'e49e0f58e273237f83b4486f3536931ed1943d18':
  h264: make sure the slices do not overlap during slice threading

Conflicts:
	libavcodec/h264.h
	libavcodec/h264_slice.c

See: 43b434210e
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-27 18:46:11 +02:00
Anton Khirnov 5ec0bdf2c5 h264: do not update the context fields copied between threads after finish_setup()
Should fix a large number of possible races with frame threading.
2015-06-27 16:48:48 +02:00
Anton Khirnov e49e0f58e2 h264: make sure the slices do not overlap during slice threading
Based on a patch by Michael Niedermayer <michaelni@gmx.at>.
CC: libav-stable@libav.org
Found-by: Kieran Kunhya <kierank@obe.tv>
2015-06-27 16:43:22 +02:00
Kieran Kunhya 22291c372f avcodec: Add support for per-frame AFD output in h264
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-26 23:11:17 +02:00
Andreas Cadhalpun 1189af4292 h264: update avctx width/height/pix_fmt when returning frame
Inconsistencies between the dimensions/pixel format of avctx and the
frame can confuse API users.
For example this can crash the demuxing_decoding example.

Back up the previous values and restore them, when decoding the next
frame. This is necessary, because these can be different between the
returned frame and the last decoded frame.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-06-12 21:22:00 +02:00
Michael Niedermayer 36f862e04c Merge commit 'a0f2946068c62e18cb05ac25c0df3d86077251a6'
* commit 'a0f2946068c62e18cb05ac25c0df3d86077251a6':
  h264: use properly allocated AVFrames

Conflicts:
	libavcodec/h264.c
	libavcodec/h264.h
	libavcodec/h264_refs.c
	libavcodec/h264_slice.c
	libavcodec/svq3.c
	libavcodec/vda_h264.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-29 16:35:24 +02:00
Michael Niedermayer 07a79cf869 Merge commit '7a4f74eed51f914e9bbfebaffd4a92ac6791f819'
* commit '7a4f74eed51f914e9bbfebaffd4a92ac6791f819':
  h264: embed the DPB in the context

Conflicts:
	libavcodec/h264.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-29 15:33:46 +02:00
Michael Niedermayer d3a5dba81b Merge commit '11f024ef0ab923ed8680fc35a087d576e549c849'
* commit '11f024ef0ab923ed8680fc35a087d576e549c849':
  h264: move freeing the escaped RBSP buffer to free_context()

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-29 13:26:33 +02:00
Michael Niedermayer ab7ad5e6a1 Merge commit 'ee62b364be0c30cba83b5ff10a3ca8c3e866ade6'
* commit 'ee62b364be0c30cba83b5ff10a3ca8c3e866ade6':
  h264: eliminate ff_h264_set_parameter_from_sps()

Conflicts:
	libavcodec/h264.c
	libavcodec/h264.h
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-29 13:23:45 +02:00
Michael Niedermayer e8a460672f Merge commit '9d33bab583a82cf12286c65258a29c6888e1ff98'
* commit '9d33bab583a82cf12286c65258a29c6888e1ff98':
  h264: drop H264Context.ouputed_poc

Conflicts:
	libavcodec/h264.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-29 11:38:42 +02:00
Michael Niedermayer 0d5e615c10 Merge commit '27b0e6ebfd47b0c11156c18b90fa8c571f0f60c3'
* commit '27b0e6ebfd47b0c11156c18b90fa8c571f0f60c3':
  h264: drop needs_realloc

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-29 11:28:28 +02:00
Anton Khirnov a0f2946068 h264: use properly allocated AVFrames 2015-04-29 05:52:58 +02:00
Anton Khirnov 7a4f74eed5 h264: embed the DPB in the context
It now has a fixed size and is initialized only once, so there is no
point in allocating it separately.
2015-04-29 05:52:58 +02:00
Anton Khirnov 11f024ef0a h264: move freeing the escaped RBSP buffer to free_context()
It does not logically belong in free_tables(), since it's not allocated
in alloc_tables() and its size has nothing to do with the frame size.
2015-04-29 05:52:58 +02:00
Anton Khirnov ee62b364be h264: eliminate ff_h264_set_parameter_from_sps()
That function currently does two things -- reinitializing the DSP
contexts and setting low_delay based on the SPS values.

The former more appropriately belongs in h264_slice_header_init(), while
the latter only really makes sense in decode_slice_header().

The third call to ff_h264_set_parameter_from_sps(), done immediately
after parsing a new SPS, appears to serve no useful purpose, so it is
just dropped.

Also, drop now unneeded H264Context.cur_chroma_format_idc.
2015-04-29 05:52:57 +02:00
Anton Khirnov 9d33bab583 h264: drop H264Context.ouputed_poc
It is only set, but never used for anything.
2015-04-29 05:52:57 +02:00
Anton Khirnov 27b0e6ebfd h264: drop needs_realloc
It is not needed anymore since switching to refcounted frames.
2015-04-29 05:52:57 +02:00
Michael Niedermayer 8f7b022c8c Merge commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25'
* commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25':
  lavc: Replace av_dlog and tprintf with internal macros

Conflicts:
	libavcodec/aacdec.c
	libavcodec/audio_frame_queue.c
	libavcodec/bitstream.c
	libavcodec/dcadec.c
	libavcodec/dnxhddec.c
	libavcodec/dvbsubdec.c
	libavcodec/dvdec.c
	libavcodec/dvdsubdec.c
	libavcodec/get_bits.h
	libavcodec/gifdec.c
	libavcodec/h264.h
	libavcodec/h264_cabac.c
	libavcodec/h264_cavlc.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_refs.c
	libavcodec/imc.c
	libavcodec/interplayvideo.c
	libavcodec/jpeglsdec.c
	libavcodec/libopencore-amr.c
	libavcodec/mjpegdec.c
	libavcodec/mpeg12dec.c
	libavcodec/mpegvideo_enc.c
	libavcodec/mpegvideo_parser.c
	libavcodec/pngdec.c
	libavcodec/ratecontrol.c
	libavcodec/rv10.c
	libavcodec/svq1dec.c
	libavcodec/vqavideo.c
	libavcodec/wmadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-20 04:10:10 +02:00
Vittorio Giovara 6a85dfc830 lavc: Replace av_dlog and tprintf with internal macros 2015-04-19 12:41:59 +01:00
Michael Niedermayer bc48c88918 avcodec/h264: Do not fail with randomly truncated VUIs
Fixes Ticket4445

Tested-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-10 18:35:07 +02:00
Michael Niedermayer 795199fca4 avcodec/h264: use consistent argument name in MB_FIELD() macro
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-08 12:29:17 +02:00
Michael Niedermayer 43b434210e avcodec/h264: Fix race between slices where one overwrites data from the next
Fixes non deterministic crash in ticket4408/fuzz2.264
Likely fixes other samples as well

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-07 00:40:21 +02:00
Michael Niedermayer 6da7625cc3 Merge commit 'a4d34e218f548d381e09c483e8dc6ad18a8d571c'
* commit 'a4d34e218f548d381e09c483e8dc6ad18a8d571c':
  h264: disable ER by default

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_picture.c
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-04 00:52:54 +02:00
Anton Khirnov a4d34e218f h264: disable ER by default
The way it is currently designed is fundamentally unsafe and cannot be
reasonably fixed without completely rewriting it.
2015-04-03 13:14:43 +02:00
Michael Niedermayer 354db19ff4 avcodec/h264: Remove bits_per_raw_sample hacks
Fixes assertion failure

Fixes: f12c79769501ee471a5c731b8304ffcb/signal_sigabrt_7ffff6ac8cc9_3766_cov_4267830138_undemuxable_h264.ts

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-25 04:14:38 +01:00
Michael Niedermayer 0346783c98 avcodec/h264.h: Drop unused macro
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-22 00:29:01 +01:00
Michael Niedermayer fa7c08d5e1 Merge commit 'c28ed1d743443e783537d279ae721be3bbdf7646'
* commit 'c28ed1d743443e783537d279ae721be3bbdf7646':
  h264: move [uv]linesize to the per-slice context

Conflicts:
	libavcodec/h264_mb.c
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 23:16:36 +01:00
Michael Niedermayer d8151a7e94 Merge commit 'a12d3188cbec15e22070e139fa5cc541da07e2c3'
* commit 'a12d3188cbec15e22070e139fa5cc541da07e2c3':
  h264: use a smaller struct for the ref lists

Conflicts:
	libavcodec/h264_direct.c
	libavcodec/h264_mb.c
	libavcodec/h264_picture.c
	libavcodec/h264_refs.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 23:05:34 +01:00
Michael Niedermayer 0f8bb0efc3 Merge commit '5bf3c0fa49afd5bbf43aa841ff78007d72c80736'
* commit '5bf3c0fa49afd5bbf43aa841ff78007d72c80736':
  h264: drop the now unused per-slice H264Contexts

Conflicts:
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 21:41:17 +01:00
Michael Niedermayer 8bdcec3111 Merge commit '51d8725a6e4c7f989d6f0f38b59cb54a2d72846c'
* commit '51d8725a6e4c7f989d6f0f38b59cb54a2d72846c':
  h264: use the main H264Context as the parent for all slice contexts

Conflicts:
	libavcodec/h264.c
	libavcodec/h264.h
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 21:33:27 +01:00
Michael Niedermayer 84ae7294cb Merge commit '3178f4d33ff62243f7cdddb081db516ea34396c9'
* commit '3178f4d33ff62243f7cdddb081db516ea34396c9':
  h264: move rbsp_buffer into the per-slice context

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_parser.c
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 20:16:21 +01:00
Michael Niedermayer 830e548b9e Merge commit '582683b6ac798ed2a004a4e2121b7bd47892bbfd'
* commit '582683b6ac798ed2a004a4e2121b7bd47892bbfd':
  h264: move remaining ER stuff into the per-slice context

Conflicts:
	libavcodec/h264.h
	libavcodec/h264_picture.c
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 20:00:34 +01:00
Michael Niedermayer 44e4a86c8a Merge commit 'c377e04d8aa74d030672e9a4788a700b0695fc14'
* commit 'c377e04d8aa74d030672e9a4788a700b0695fc14':
  h264: move top_borders into the per-slice context

Conflicts:
	libavcodec/h264.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 18:58:59 +01:00
Michael Niedermayer 3d1d8e1f95 Merge commit '36d04801ba9d8622c2d759c172aea18561bac74d'
* commit '36d04801ba9d8622c2d759c172aea18561bac74d':
  h264: move the scratch buffers into the per-slice context

Conflicts:
	libavcodec/h264.h
	libavcodec/h264_slice.c
	libavcodec/svq3.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 18:50:53 +01:00
Michael Niedermayer 2730163329 Merge commit '34d4c605e9a5116d5289b35633ade5b01cacab24'
* commit '34d4c605e9a5116d5289b35633ade5b01cacab24':
  h264_loopfilter: constify all uses of H264Context

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-21 18:26:10 +01:00