Compare commits

..

No commits in common. "master" and "n3.2-dev" have entirely different histories.

450 changed files with 6651 additions and 15419 deletions

View File

@ -2,16 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version <next>:
- libopenmpt demuxer
- tee protocol
- Changed metadata print option to accept general urls
- Alias muxer for Ogg Video (.ogv)
- VP8 in Ogg muxing
- curves filter doesn't automatically insert points at x=0 and x=1 anymore
- 16-bit support in curves filter
- 16-bit support in selectivecolor filter
- OpenH264 decoder wrapper
- MediaCodec hwaccel
- YUY2 Lossless Codec decoder
version 3.1:
@ -57,8 +48,6 @@ version 3.1:
- CUDA CUVID H264/HEVC decoder
- 10-bit depth support in native utvideo decoder
- libutvideo wrapper removed
- YUY2 Lossless Codec decoder
- VideoToolbox H.264 encoder
version 3.0:

View File

@ -43,7 +43,7 @@ Miscellaneous Areas
===================
documentation Stefano Sabatini, Mike Melanson, Timothy Gu, Lou Logan
project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser, Nikolay Aleksandrov
project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser
presets Robert Swain
metadata subsystem Aurelien Jacobs
release management Michael Niedermayer
@ -147,7 +147,7 @@ Codecs:
celp_filters.* Vitor Sessak
cinepak.c Roberto Togni
cinepakenc.c Rl / Aetey G.T. AB
ccaption_dec.c Anshul Maheshwari, Aman Gupta
ccaption_dec.c Anshul Maheshwari
cljr Alex Beregszaszi
cpia.c Stephan Hilb
crystalhd.c Philip Langdale
@ -308,7 +308,6 @@ Filters:
af_chorus.c Paul B Mahol
af_compand.c Paul B Mahol
af_firequalizer.c Muhammad Faiz
af_hdcd.c Burt P.
af_ladspa.c Paul B Mahol
af_loudnorm.c Kyle Swanson
af_pan.c Nicolas George
@ -403,7 +402,6 @@ Muxers/Demuxers:
jvdec.c Peter Ross
libmodplug.c Clément Bœsch
libnut.c Oded Shimon
libopenmpt.c Josh de Kock
lmlm4.c Ivo van Poorten
lvfdec.c Paul B Mahol
lxfdec.c Tomas Härdin
@ -522,6 +520,7 @@ Releases
2.7 Michael Niedermayer
2.6 Michael Niedermayer
2.5 Michael Niedermayer
2.4 Michael Niedermayer
If you want to maintain an older release, please contact us
@ -547,7 +546,6 @@ Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
Lou Logan 7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A
Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93
Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1
Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029
Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B
Philip Langdale 5DC5 8D66 5FBA 3A43 18EC 045E F8D6 B194 6A75 682E

View File

@ -83,7 +83,12 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
%.h.c:
$(Q)echo '#include "$*.h"' >$@
%.c %.h %.ver: TAG = GEN
%.ver: %.v
$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ | sed -e 's/:/:\
/' -e 's/; /;\
/g' > $@
%.c %.h: TAG = GEN
# Dummy rule to stop make trying to rebuild removed or renamed headers
%.h:
@ -147,7 +152,7 @@ $(TOOLOBJS): | tools
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.ho *$(DEFAULT_YASMD).asm
CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ver-sol2 *.ho *.gcno *.gcda *$(DEFAULT_YASMD).asm
DISTCLEANSUFFIXES = *.pc
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a

63
configure vendored
View File

@ -245,7 +245,6 @@ External library support:
--enable-libopencv enable video filtering via libopencv [no]
--enable-libopenh264 enable H.264 encoding via OpenH264 [no]
--enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
--enable-libopenmpt enable decoding tracked files via libopenmpt [no]
--enable-libopus enable Opus de/encoding via libopus [no]
--enable-libpulse enable Pulseaudio input via libpulse [no]
--enable-librubberband enable rubberband needed for rubberband filter [no]
@ -1506,7 +1505,6 @@ EXTERNAL_LIBRARY_LIST="
libopencv
libopenh264
libopenjpeg
libopenmpt
libopus
libpulse
librtmp
@ -2213,8 +2211,6 @@ setend_deps="arm"
map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
loongson2_deps="mips"
loongson3_deps="mips"
mipsfpu_deps="mips"
mipsdsp_deps="mips"
mipsdspr2_deps="mips"
@ -2559,7 +2555,6 @@ h264_d3d11va_hwaccel_select="h264_decoder"
h264_dxva2_hwaccel_deps="dxva2"
h264_dxva2_hwaccel_select="h264_decoder"
h264_mediacodec_decoder_deps="mediacodec"
h264_mediacodec_hwaccel_deps="mediacodec"
h264_mediacodec_decoder_select="h264_mp4toannexb_bsf h264_parser"
h264_mmal_decoder_deps="mmal"
h264_mmal_decoder_select="mmal"
@ -2771,12 +2766,9 @@ libopencore_amrnb_decoder_deps="libopencore_amrnb"
libopencore_amrnb_encoder_deps="libopencore_amrnb"
libopencore_amrnb_encoder_select="audio_frame_queue"
libopencore_amrwb_decoder_deps="libopencore_amrwb"
libopenh264_decoder_deps="libopenh264"
libopenh264_decoder_select="h264_mp4toannexb_bsf"
libopenh264_encoder_deps="libopenh264"
libopenjpeg_decoder_deps="libopenjpeg"
libopenjpeg_encoder_deps="libopenjpeg"
libopenmpt_demuxer_deps="libopenmpt"
libopus_decoder_deps="libopus"
libopus_encoder_deps="libopus"
libopus_encoder_select="audio_frame_queue"
@ -2862,7 +2854,6 @@ nut_muxer_select="riffenc"
nuv_demuxer_select="riffdec"
oga_muxer_select="ogg_muxer"
ogg_demuxer_select="dirac_parse"
ogv_muxer_select="ogg_muxer"
opus_muxer_select="ogg_muxer"
psp_muxer_select="mov_muxer"
rtp_demuxer_select="sdp_demuxer"
@ -3157,7 +3148,6 @@ objformat="elf"
pkg_config_default=pkg-config
ranlib_default="ranlib"
strip_default="strip"
version_script='--version-script'
yasmexe_default="yasm"
windres_default="windres"
@ -3219,7 +3209,6 @@ SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
VERSION_SCRIPT_POSTPROCESS_CMD="cat"
asflags_filter=echo
cflags_filter=echo
@ -3804,11 +3793,11 @@ suncc_flags(){
westmere) echo -xtarget=westmere ;;
silvermont) echo -xarch=sse4_2 ;;
corei7-avx|sandybridge) echo -xtarget=sandybridge ;;
core-avx*|ivybridge|haswell|broadwell|skylake*|knl)
core-avx*|ivybridge|haswell|broadwell)
echo -xarch=avx ;;
amdfam10|barcelona) echo -xtarget=barcelona ;;
btver1) echo -xarch=amdsse4a ;;
btver2|bdver*|znver*) echo -xarch=avx ;;
btver2|bdver*) echo -xarch=avx ;;
athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
k8|opteron|athlon64|athlon-fx)
echo -xarch=sse2a ;;
@ -4504,8 +4493,7 @@ elif enabled x86; then
;;
# targets that do support nopl and conditional mov (cmov)
i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx\
|core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|skylake*|knl\
|amdfam10|barcelona|b[dt]ver*|znver*)
|core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|amdfam10|barcelona|b[dt]ver*)
cpuflags="-march=$cpu"
enable i686
enable fast_cmov
@ -4541,7 +4529,7 @@ fi
add_cppflags -D_ISOC99_SOURCE
add_cxxflags -D__STDC_CONSTANT_MACROS
add_cxxflags -std=c++98
add_cxxflags -std=c++11
check_cflags -std=c99
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
#include <stdlib.h>
@ -4639,8 +4627,7 @@ case $target_os in
echo "hwcap_1 = OVERRIDE;" > mapfile &&
add_ldflags -Wl,-M,mapfile
nm_default='nm -P -g'
version_script='-M'
VERSION_SCRIPT_POSTPROCESS_CMD='perl $(SRC_PATH)/compat/solaris/make_sunver.pl - $(OBJS)'
SLIB_CREATE_DEF_CMD='$(Q)perl $(SRC_PATH)/compat/solaris/make_sunver.pl $$(filter %.ver,$$^) $(OBJS) | grep -v @ > $(SUBDIR)lib$(NAME).ver-sol2'
;;
netbsd)
disable symver
@ -5638,8 +5625,7 @@ enabled cuvid && { check_lib cuviddec.h cuvidCreateDecoder -lnvcuvid
enabled chromaprint && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint
enabled coreimage_filter && { check_header_objcc QuartzCore/CoreImage.h || disable coreimage_filter; }
enabled coreimagesrc_filter && { check_header_objcc QuartzCore/CoreImage.h || disable coreimagesrc_filter; }
enabled decklink && { { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; } &&
{ check_cpp_condition DeckLinkAPIVersion.h "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a060100" || die "ERROR: Decklink API version must be >= 10.6.1."; } }
enabled decklink && { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; }
enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
enabled gmp && require2 gmp gmp.h mpz_export -lgmp
enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
@ -5688,7 +5674,6 @@ enabled libopenjpeg && { check_lib openjpeg-2.1/openjpeg.h opj_version -lo
check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
check_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
die "ERROR: libopenjpeg not found"; }
enabled libopenmpt && require_pkg_config "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create
enabled libopus && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
enabled libpulse && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new
enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
@ -6038,8 +6023,6 @@ enabled neon_clobber_test &&
-Wl,--wrap,avcodec_decode_subtitle2 \
-Wl,--wrap,avcodec_encode_audio2 \
-Wl,--wrap,avcodec_encode_video2 \
-Wl,--wrap,avcodec_send_packet \
-Wl,--wrap,avcodec_receive_frame \
-Wl,--wrap,avcodec_encode_subtitle \
-Wl,--wrap,swr_convert \
-Wl,--wrap,avresample_convert ||
@ -6053,33 +6036,26 @@ enabled xmm_clobber_test &&
-Wl,--wrap,avcodec_encode_audio2 \
-Wl,--wrap,avcodec_encode_video2 \
-Wl,--wrap,avcodec_encode_subtitle \
-Wl,--wrap,avcodec_send_packet \
-Wl,--wrap,avcodec_receive_frame \
-Wl,--wrap,swr_convert \
-Wl,--wrap,avresample_convert \
-Wl,--wrap,sws_scale ||
disable xmm_clobber_test
check_ld "cc" <<EOF && enable proper_dce
extern const int array[512];
static inline int func(void) { return array[0]; }
int main(void) { return 0; }
EOF
echo "X { local: *; };" > $TMPV
if test_ldflags -Wl,--version-script,$TMPV; then
append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
elif test_ldflags -Wl,-M,$TMPV; then
append SHFLAGS '-Wl,-M,\$(SUBDIR)lib\$(NAME).ver-sol2'
fi
if enabled proper_dce; then
echo "X { local: *; };" > $TMPV
if test_ldflags -Wl,${version_script},$TMPV; then
append SHFLAGS '-Wl,${version_script},\$(SUBDIR)lib\$(NAME).ver'
check_cc <<EOF && enable symver_asm_label
check_cc <<EOF && enable symver_asm_label
void ff_foo(void) __asm__ ("av_foo@VERSION");
void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
EOF
check_cc <<EOF && enable symver_gnu_asm
check_cc <<EOF && enable symver_gnu_asm
__asm__(".symver ff_foo,av_foo@VERSION");
void ff_foo(void) {}
EOF
fi
fi
if [ -z "$optflags" ]; then
if enabled small; then
@ -6149,7 +6125,11 @@ elif enabled ccc; then
add_cflags -msg_disable nonstandcast
add_cflags -msg_disable unsupieee
elif enabled gcc; then
check_optflags -fno-tree-vectorize
case $gcc_basever in
4.9*) enabled x86 || check_optflags -fno-tree-vectorize ;;
4.*) check_optflags -fno-tree-vectorize ;;
*) enabled x86 || check_optflags -fno-tree-vectorize ;;
esac
check_cflags -Werror=format-security
check_cflags -Werror=implicit-function-declaration
check_cflags -Werror=missing-prototypes
@ -6214,10 +6194,6 @@ __declspec($_restrict) void* foo(int);
EOF
fi
check_func strtoll || add_cflags -Dstrtoll=_strtoi64
# the new SSA optimzer in VS2015 U3 is mis-optimizing some parts of the code
# this flag should be re-checked on newer compiler releases and put under a
# version check once its fixed
check_cflags -d2SSAOptimizer-
fi
for pfx in "" host_; do
@ -6611,7 +6587,6 @@ SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
VERSION_SCRIPT_POSTPROCESS_CMD=${VERSION_SCRIPT_POSTPROCESS_CMD}
SAMPLES:=${samples:-\$(FATE_SAMPLES)}
NOREDZONE_FLAGS=$noredzone_flags
EOF

View File

@ -15,33 +15,14 @@ libavutil: 2015-08-28
API changes, most recent first:
2016-07-09 - xxxxxxx / 90f469a - lavc 57.50.100 / 57.20.0 - avcodec.h
Add FF_PROFILE_H264_MULTIVIEW_HIGH and FF_PROFILE_H264_STEREO_HIGH.
2016-06-30 - c1c7e0ab - lavf 57.41.100 - avformat.h
Moved codecpar field from AVStream to the end of the struct, so that
the following private fields are in the same location as in FFmpeg 3.0 (lavf 57.25.100).
2016-06-30 - 042fb69d - lavu 55.28.100 - frame.h
Moved hw_frames_ctx field from AVFrame to the end of the struct, so that
the following private fields are in the same location as in FFmpeg 3.0 (lavu 55.17.103).
2016-06-29 - 1a751455 - lavfi 6.47.100 - avfilter.h
Fix accidental ABI breakage in AVFilterContext.
ABI was broken in 8688d3a, lavfi 6.42.100 and released as ffmpeg 3.1.
Because of this, ffmpeg and ffplay built against lavfi>=6.42.100 will not be
compatible with lavfi>=6.47.100. Potentially also affects other users of
libavfilter if they are using one of the affected fields.
-------- 8< --------- FFmpeg 3.1 was cut here -------- 8< ---------
2016-06-26 - 481f320 / 1c9e861 - lavu 55.27.100 / 55.13.0 - hwcontext.h
2016-06-26 - xxxxxxx / 1c9e861 - lavu 55.27.100 / 55.13.0 - hwcontext.h
Add av_hwdevice_ctx_create().
2016-06-26 - b95534b / e47b8bb - lavc 57.48.101 / 57.19.1 - avcodec.h
2016-06-26 - xxxxxxx / e47b8bb - lavc 57.48.101 / 57.19.1 - avcodec.h
Adjust values for JPEG 2000 profiles.
-------- 8< --------- FFmpeg 3.1 was cut here -------- 8< ---------
2016-06-23 - 5d75e46 / db7968b - lavf 57.40.100 / 57.7.0 - avio.h
Add AVIODataMarkerType, write_data_type, ignore_boundary_point and
avio_write_marker.

File diff suppressed because it is too large Load Diff

View File

@ -125,7 +125,7 @@ $(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
OBJDIRS += doc/examples
DOXY_INPUT = $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) $(LIB_EXAMPLES:%$(EXESUF)=%.c)
DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) config.mak
DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT))
doc/doxy/html: TAG = DOXY
doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT_DEPS)

View File

@ -279,7 +279,7 @@ present between the subtitle lines because of double-sized teletext charactes.
Default value is 1.
@item txt_duration
Sets the display duration of the decoded teletext pages or subtitles in
milliseconds. Default value is 30000 which is 30 seconds.
miliseconds. Default value is 30000 which is 30 seconds.
@item txt_transparent
Force transparent background of the generated teletext bitmaps. Default value
is 0 which means an opaque background.

View File

@ -267,33 +267,6 @@ track. Track indexes start at 0. The demuxer exports the number of tracks as
For very large files, the @option{max_size} option may have to be adjusted.
@section libopenmpt
libopenmpt based module demuxer
See @url{https://lib.openmpt.org/libopenmpt/} for more information.
Some files have multiple subsongs (tracks) this can be set with the @option{subsong}
option.
It accepts the following options:
@table @option
@item subsong
Set the subsong index. This can be either 'all', 'auto', or the index of the
subsong. Subsong indexes start at 0. The default is 'auto'.
The default value is to let libopenmpt choose.
@item layout
Set the channel layout. Valid values are 1, 2, and 4 channel layouts.
The default value is STEREO.
@item sample_rate
Set the sample rate for libopenmpt to output.
Range is from 1000 to INT_MAX. The value default is 48000.
@end table
@section gif
Animated GIF demuxer.

View File

@ -1184,17 +1184,6 @@ following: 4000, 6000, 8000, 12000, or 20000, corresponding to
narrowband, mediumband, wideband, super wideband, and fullband
respectively. The default is 0 (cutoff disabled).
@item mapping_family (@emph{mapping_family})
Set channel mapping family to be used by the encoder. The default value of -1
uses mapping family 0 for mono and stereo inputs, and mapping family 1
otherwise. The default also disables the surround masking and LFE bandwidth
optimzations in libopus, and requires that the input contains 8 channels or
fewer.
Other values include 0 for mono and stereo, 1 for surround sound with masking
and LFE bandwidth optimizations, and 255 for independent streams with an
unspecified channel layout.
@end table
@section libvorbis
@ -1401,7 +1390,7 @@ is 0. This is only used when @option{slice_mode} is set to
@samp{fixed}.
@item slice_mode
Set slice mode. Can assume one of the following possible values:
Set slice mode. Can assume one of the follwing possible values:
@table @samp
@item fixed

View File

@ -129,7 +129,6 @@
<xsd:complexType name="frameSideDataType">
<xsd:attribute name="side_data_type" type="xsd:string"/>
<xsd:attribute name="side_data_size" type="xsd:int" />
<xsd:attribute name="timecode" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="subtitleType">

View File

@ -3243,7 +3243,7 @@ silenceremove=1:5:0.02
@end example
@item
Trim all silence encountered from beginning to end where there is more than 1
Trim all silence encountered from begining to end where there is more than 1
second of silence in audio:
@example
silenceremove=0:0:0:-1:1:-90dB
@ -4713,7 +4713,7 @@ ffmpeg -f lavfi -i color=c=black:s=1280x720 -i video.mp4 -shortest -filter_compl
Display CIE color diagram with pixels overlaid onto it.
The filter accepts the following options:
The filter acccepts the following options:
@table @option
@item system
@ -4743,7 +4743,7 @@ Set CIE system.
@item gamuts
Set what gamuts to draw.
See @code{system} option for available values.
See @code{system} option for avaiable values.
@item size, s
Set ciescope size, by default set to 512.
@ -5710,6 +5710,10 @@ strictly increasing over the x-axis, and their @var{x} and @var{y} values must
be in the @var{[0;1]} interval. If the computed curves happened to go outside
the vector spaces, the values will be clipped accordingly.
If there is no key point defined in @code{x=0}, the filter will automatically
insert a @var{(0;0)} point. In the same way, if there is no key point defined
in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
The filter accepts the following options:
@table @option
@ -5750,8 +5754,6 @@ options. In this case, the unset component(s) will fallback on this
@option{all} setting.
@item psfile
Specify a Photoshop curves file (@code{.acv}) to import the settings from.
@item plot
Save Gnuplot script of the curves in specified file.
@end table
To avoid some filtergraph syntax conflicts, each key points list need to be
@ -5763,13 +5765,13 @@ defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
@item
Increase slightly the middle level of blue:
@example
curves=blue='0/0 0.5/0.58 1/1'
curves=blue='0.5/0.58'
@end example
@item
Vintage effect:
@example
curves=r='0/0.11 .42/.51 1/0.95':g='0/0 0.50/0.48 1/1':b='0/0.22 .49/.44 1/0.8'
curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
@end example
Here we obtain the following coordinates for each components:
@table @var
@ -5796,15 +5798,7 @@ curves=vintage
@item
Use a Photoshop preset and redefine the points of the green component:
@example
curves=psfile='MyCurvesPresets/purple.acv':green='0/0 0.45/0.53 1/1'
@end example
@item
Check out the curves of the @code{cross_process} profile using @command{ffmpeg}
and @command{gnuplot}:
@example
ffmpeg -f lavfi -i color -vf curves=cross_process:plot=/tmp/curves.plt -frames:v 1 -f null -
gnuplot -p /tmp/curves.plt
curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
@end example
@end itemize
@ -6438,9 +6432,6 @@ Scroll from right to left.
@item rscroll
Scroll from left to right.
@item picture
Draw single picture.
@end table
Default is @code{frame}.
@ -8436,23 +8427,8 @@ ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
@section hdcd
Decodes High Definition Compatible Digital (HDCD) data. A 16-bit PCM stream with
embedded HDCD codes is expanded into a 20-bit PCM stream.
The filter supports the Peak Extend and Low-level Gain Adjustment features
of HDCD, and detects the Transient Filter flag.
@example
ffmpeg -i HDCD16.flac -af hdcd OUT24.flac
@end example
When using the filter with wav, note the default encoding for wav is 16-bit,
so the resulting 20-bit stream will be truncated back to 16-bit. Use something
like @command{-acodec pcm_s24le} after the filter to get 24-bit PCM output.
@example
ffmpeg -i HDCD16.wav -af hdcd OUT16.wav
ffmpeg -i HDCD16.wav -af hdcd -acodec pcm_s24le OUT24.wav
@end example
Decodes high definition audio cd data. 16-Bit PCM stream containing hdcd flags
is converted to 20-bit PCM stream.
@section hflip
@ -9399,14 +9375,13 @@ Float representation of @code{value} from metadata key.
@item VALUE2
Float representation of @code{value} as supplied by user in @code{value} option.
@item file
If specified in @code{print} mode, output is written to the named file. Instead of
plain filename any writable url can be specified. Filename ``-'' is a shorthand
for standard output. If @code{file} option is not set, output is written to the log
with AV_LOG_INFO loglevel.
@end table
@item file
If specified in @code{print} mode, output is written to the named file. When
filename equals "-" data is written to standard output.
If @code{file} option is not set, output is written to the log with AV_LOG_INFO
loglevel.
@end table
@subsection Examples
@ -9416,18 +9391,8 @@ with AV_LOG_INFO loglevel.
Print all metadata values for frames with key @code{lavfi.singnalstats.YDIF} with values
between 0 and 1.
@example
@end example
signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)'
@end example
@item
Print silencedetect output to file @file{metadata.txt}.
@example
silencedetect,ametadata=mode=print:file=metadata.txt
@end example
@item
Direct all metadata to a pipe with file descriptor 4.
@example
metadata=mode=print:file='pipe\:4'
@end example
@end itemize
@section mpdecimate
@ -10692,31 +10657,13 @@ The description of the accepted parameters follows.
If specified the filter will use the named file to save the PSNR of
each individual frame. When filename equals "-" the data is sent to
standard output.
@item stats_version
Specifies which version of the stats file format to use. Details of
each format are written below.
Default value is 1.
@end table
The file printed if @var{stats_file} is selected, contains a sequence of
key/value pairs of the form @var{key}:@var{value} for each compared
couple of frames.
If a @var{stats_version} greater than 1 is specified, a header line precedes
the list of per-frame-pair stats, with key value pairs following the frame
format with the following parameters:
@table @option
@item psnr_log_version
The version of the log file format. Will match @var{stats_version}.
@item fields
A comma separated list of the per-frame-pair parameters included in
the log.
@end table
A description of each shown per-frame-pair parameter follows:
A description of each shown parameter follows:
@table @option
@item n
@ -11219,16 +11166,16 @@ Set luma maximum difference between pixels to still be considered, must
be a value in the 0.1-100.0 range, default value is 1.0.
@item chroma_radius, cr
Set chroma blur filter strength, must be a value in range -0.9-4.0. A
Set chroma blur filter strength, must be a value in range 0.1-4.0. A
greater value will result in a more blurred image, and in slower
processing.
@item chroma_pre_filter_radius, cpfr
Set chroma pre-filter radius, must be a value in the -0.9-2.0 range.
Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
@item chroma_strength, cs
Set chroma maximum difference between pixels to still be considered,
must be a value in the -0.9-100.0 range.
must be a value in the 0.1-100.0 range.
@end table
Each chroma option value, if not explicitly specified, is set to the
@ -12372,9 +12319,6 @@ interleaved columns, left eye first
@item icr
interleaved columns, right eye first
@item hdmi
HDMI frame pack
@end table
Default value is @samp{arcd}.

View File

@ -103,19 +103,12 @@ enable it.
@section OpenH264
FFmpeg can make use of the OpenH264 library for H.264 encoding and decoding.
FFmpeg can make use of the OpenH264 library for H.264 encoding.
Go to @url{http://www.openh264.org/} and follow the instructions for
installing the library. Then pass @code{--enable-libopenh264} to configure to
enable it.
For decoding, this library is much more limited than the built-in decoder
in libavcodec; currently, this library lacks support for decoding B-frames
and some other main/high profile features. (It currently only supports
constrained baseline profile and CABAC.) Using it is mostly useful for
testing and for taking advantage of Cisco's patent portfolio license
(@url{http://www.openh264.org/BINARY_LICENSE.txt}).
@section x264
FFmpeg can make use of the x264 library for H.264 encoding.
@ -686,8 +679,6 @@ following image formats are supported:
@tab fourcc: DUCK
@item Duck TrueMotion 2.0 @tab @tab X
@tab fourcc: TM20
@item Duck TrueMotion 2.0 RT @tab @tab X
@tab fourcc: TR20
@item DV (Digital Video) @tab X @tab X
@item Dxtory capture format @tab @tab X
@item Feeble Files/ScummVM DXA @tab @tab X
@ -754,7 +745,7 @@ following image formats are supported:
@item LucasArts SANM/Smush @tab @tab X
@tab Used in LucasArts games / SMUSH animations.
@item lossless MJPEG @tab X @tab X
@item MagicYUV Video @tab @tab X
@item MagicYUV Lossless Video @tab @tab X
@item Microsoft ATC Screen @tab @tab X
@tab Also known as Microsoft Screen 3.
@item Microsoft Expression Encoder Screen @tab @tab X

View File

@ -251,28 +251,6 @@ To use this option, ffmpeg needs to be compiled with @code{--enable-libzvbi}.
Defines number of audio channels to capture. Must be @samp{2}, @samp{8} or @samp{16}.
Defaults to @samp{2}.
@item duplex_mode
Sets the decklink device duplex mode. Must be @samp{unset}, @samp{half} or @samp{full}.
Defaults to @samp{unset}.
@item video_input
Sets the video input source. Must be @samp{unset}, @samp{sdi}, @samp{hdmi},
@samp{optical_sdi}, @samp{component}, @samp{composite} or @samp{s_video}.
Defaults to @samp{unset}.
@item audio_input
Sets the audio input source. Must be @samp{unset}, @samp{embedded},
@samp{aes_ebu}, @samp{analog}, @samp{analog_xlr}, @samp{analog_rca} or
@samp{microphone}. Defaults to @samp{unset}.
@item video_pts
Sets the video packet timestamp source. Must be @samp{video}, @samp{audio},
@samp{reference} or @samp{wallclock}. Defaults to @samp{video}.
@item audio_pts
Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio},
@samp{reference} or @samp{wallclock}. Defaults to @samp{audio}.
@end table
@subsection Examples

View File

@ -396,8 +396,8 @@ which can be cyclic, for example if the @option{wrap} option is
specified.
@item hls_segment_filename @var{filename}
Set the segment filename. Unless @code{hls_flags single_file} is set,
@var{filename} is used as a string format with the segment number:
Set the segment filename. Unless hls_flags single_file is set @var{filename}
is used as a string format with the segment number:
@example
ffmpeg in.nut -hls_segment_filename 'file%03d.ts' out.m3u8
@end example
@ -495,23 +495,6 @@ Will produce the playlist, @file{out.m3u8}, and a single segment file,
Segment files removed from the playlist are deleted after a period of time
equal to the duration of the segment plus the duration of the playlist.
@item hls_flags round_durations
Round the duration info in the playlist file segment info to integer
values, instead of using floating point.
@item hls_flags discont_starts
Add the @code{#EXT-X-DISCONTINUITY} tag to the playlist, before the
first segment's information.
@item hls_flags omit_endlist
Do not append the @code{EXT-X-ENDLIST} tag at the end of the playlist.
@item hls_flags split_by_time
Allow segments to start on frames other than keyframes. This improves
behavior on some players when the time between keyframes is inconsistent,
but may make things worse on others, and can cause some oddities during
seeking. This flag should be used with the @code{hls_time} option.
@item hls_playlist_type event
Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 header. Forces
@option{hls_list_size} to 0; the playlist can only be appended to.
@ -519,17 +502,6 @@ Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 header. Forces
@item hls_playlist_type vod
Emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8 header. Forces
@option{hls_list_size} to 0; the playlist must not change.
@item method
Use the given HTTP method to create the hls files.
@example
ffmpeg -re -i in.ts -f hls -method PUT http://example.com/live/out.m3u8
@end example
This example will upload all the mpegts segment files to the HTTP
server using the HTTP PUT method, and update the m3u8 files every
@code{refresh} times using the same method.
Note that the HTTP server must support the given method for uploading
files.
@end table
@anchor{ico}

View File

@ -695,7 +695,7 @@ This protocol accepts the following options.
@table @option
@item timeout
Set timeout in milliseconds of socket I/O operations used by the underlying
Set timeout in miliseconds of socket I/O operations used by the underlying
low level operation. By default it is set to -1, which means that the timeout
is not specified.
@ -1159,15 +1159,6 @@ Play an AVI file directly from a TAR archive:
subfile,,start,183241728,end,366490624,,:archive.tar
@end example
@section tee
Writes the output to multiple protocols. The individual outputs are separated
by |
@example
tee:file://path/to/local/this.avi|file://path/to/local/that.avi
@end example
@section tcp
Transmission Control Protocol.

View File

@ -3019,7 +3019,6 @@ static int transcode_init(void)
enc_ctx->width = dec_ctx->width;
enc_ctx->height = dec_ctx->height;
enc_ctx->has_b_frames = dec_ctx->has_b_frames;
enc_ctx->profile = dec_ctx->profile;
if (ost->frame_aspect_ratio.num) { // overridden by the -aspect cli option
sar =
av_mul_q(ost->frame_aspect_ratio,
@ -3500,12 +3499,12 @@ static int check_keyboard_interaction(int64_t cur_time)
key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for stream %d: ret:%d res:\n%s", i, ret, buf);
} else if (key == 'c') {
fprintf(stderr, "Queuing commands only on filters supporting the specific command is unsupported\n");
fprintf(stderr, "Queing commands only on filters supporting the specific command is unsupported\n");
ret = AVERROR_PATCHWELCOME;
} else {
ret = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time);
if (ret < 0)
fprintf(stderr, "Queuing command failed with error %s\n", av_err2str(ret));
fprintf(stderr, "Queing command failed with error %s\n", av_err2str(ret));
}
}
}

View File

@ -3384,6 +3384,9 @@ const OptionDef options[] = {
{ "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) },
"select output format used with HW accelerated decoding", "format" },
{ "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) },
"select output format used with HW accelerated decoding", "format" },
#if CONFIG_VDA || CONFIG_VIDEOTOOLBOX
{ "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" },
#endif

View File

@ -2725,7 +2725,7 @@ static int stream_component_open(VideoState *is, int stream_index)
goto fail;
link = is->out_audio_filter->inputs[0];
sample_rate = link->sample_rate;
nb_channels = avfilter_link_get_channels(link);
nb_channels = link->channels;
channel_layout = link->channel_layout;
}
#else
@ -2936,7 +2936,7 @@ static int read_thread(void *arg)
AVStream *st = ic->streams[i];
enum AVMediaType type = st->codecpar->codec_type;
st->discard = AVDISCARD_ALL;
if (type >= 0 && wanted_stream_spec[type] && st_index[type] == -1)
if (wanted_stream_spec[type] && st_index[type] == -1)
if (avformat_match_stream_specifier(ic, st, wanted_stream_spec[type]) > 0)
st_index[type] = i;
}

View File

@ -3277,7 +3277,6 @@ int main(int argc, char **argv)
SET_DO_SHOW(FRAME_TAGS, frame_tags);
SET_DO_SHOW(PROGRAM_TAGS, program_tags);
SET_DO_SHOW(STREAM_TAGS, stream_tags);
SET_DO_SHOW(PROGRAM_STREAM_TAGS, stream_tags);
SET_DO_SHOW(PACKET_TAGS, packet_tags);
if (do_bitexact && (do_show_program_version || do_show_library_versions)) {

View File

@ -10,7 +10,6 @@ HEADERS = avcodec.h \
dv_profile.h \
dxva2.h \
jni.h \
mediacodec.h \
qsv.h \
vaapi.h \
vda.h \
@ -36,7 +35,6 @@ OBJS = allcodecs.o \
imgconvert.o \
jni.o \
mathtables.o \
mediacodec.o \
options.o \
parser.o \
profiles.o \
@ -94,7 +92,7 @@ OBJS-$(CONFIG_LSP) += lsp.o
OBJS-$(CONFIG_LZF) += lzf.o
OBJS-$(CONFIG_MDCT) += mdct_fixed.o mdct_float.o mdct_fixed_32.o
OBJS-$(CONFIG_ME_CMP) += me_cmp.o
OBJS-$(CONFIG_MEDIACODEC) += mediacodecdec.o mediacodec_surface.o mediacodec_wrapper.o mediacodec_sw_buffer.o
OBJS-$(CONFIG_MEDIACODEC) += mediacodecdec.o mediacodec_wrapper.o mediacodec_sw_buffer.o
OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o
OBJS-$(CONFIG_MPEGAUDIO) += mpegaudio.o mpegaudiodata.o \
mpegaudiodecheader.o
@ -238,8 +236,7 @@ OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \
OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o
OBJS-$(CONFIG_DDS_DECODER) += dds.o
OBJS-$(CONFIG_DIRAC_DECODER) += diracdec.o dirac.o diracdsp.o diractab.o \
dirac_arith.o mpeg12data.o dirac_dwt.o \
dirac_vlc.o
dirac_arith.o mpeg12data.o dirac_dwt.o
OBJS-$(CONFIG_DFA_DECODER) += dfa.o
OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o
OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o
@ -309,7 +306,7 @@ OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \
intelh263dec.o h263data.o
OBJS-$(CONFIG_H263_ENCODER) += mpeg4videoenc.o mpeg4video.o \
h263.o ituh263enc.o flvenc.o h263data.o
OBJS-$(CONFIG_H264_DECODER) += h264dec.o h264_cabac.o h264_cavlc.o \
OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \
h264_direct.o h264_loopfilter.o \
h264_mb.o h264_picture.o h264_ps.o \
h264_refs.o h264_sei.o \
@ -531,8 +528,7 @@ OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o
OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o svq13.o h263data.o
OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o h263data.o \
h263.o ituh263enc.o
OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o \
h264_parse.o h264data.o h264_ps.o h2645_parse.o
OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o h264_parse.o h264data.o
OBJS-$(CONFIG_TEXT_DECODER) += textdec.o ass.o
OBJS-$(CONFIG_TEXT_ENCODER) += srtenc.o ass_split.o
OBJS-$(CONFIG_TAK_DECODER) += takdec.o tak.o takdsp.o
@ -552,7 +548,7 @@ OBJS-$(CONFIG_TRUESPEECH_DECODER) += truespeech.o
OBJS-$(CONFIG_TSCC_DECODER) += tscc.o msrledec.o
OBJS-$(CONFIG_TSCC2_DECODER) += tscc2.o
OBJS-$(CONFIG_TTA_DECODER) += tta.o ttadata.o ttadsp.o
OBJS-$(CONFIG_TTA_ENCODER) += ttaenc.o ttaencdsp.o ttadata.o
OBJS-$(CONFIG_TTA_ENCODER) += ttaenc.o ttadata.o
OBJS-$(CONFIG_TWINVQ_DECODER) += twinvqdec.o twinvq.o
OBJS-$(CONFIG_TXD_DECODER) += txd.o
OBJS-$(CONFIG_ULTI_DECODER) += ulti.o
@ -841,9 +837,9 @@ OBJS-$(CONFIG_AMR_NB_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_EAC3_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_GSM_MS_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_ILBC_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_MP1_AT_DECODER) += audiotoolboxdec.o mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP2_AT_DECODER) += audiotoolboxdec.o mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP3_AT_DECODER) += audiotoolboxdec.o mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP1_AT_DECODER) += audiotoolboxdec.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP2_AT_DECODER) += audiotoolboxdec.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP3_AT_DECODER) += audiotoolboxdec.o mpegaudiodecheader.o
OBJS-$(CONFIG_PCM_MULAW_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_PCM_ALAW_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_QDMC_AT_DECODER) += audiotoolboxdec.o
@ -864,12 +860,11 @@ OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsmenc.o
OBJS-$(CONFIG_LIBILBC_DECODER) += libilbc.o
OBJS-$(CONFIG_LIBILBC_ENCODER) += libilbc.o
OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o
OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o mpegaudiodecheader.o
OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o
OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o
OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER) += libopencore-amr.o
OBJS-$(CONFIG_LIBOPENH264_DECODER) += libopenh264dec.o libopenh264.o
OBJS-$(CONFIG_LIBOPENH264_ENCODER) += libopenh264enc.o libopenh264.o
OBJS-$(CONFIG_LIBOPENH264_ENCODER) += libopenh264enc.o
OBJS-$(CONFIG_LIBOPENJPEG_DECODER) += libopenjpegdec.o
OBJS-$(CONFIG_LIBOPENJPEG_ENCODER) += libopenjpegenc.o
OBJS-$(CONFIG_LIBOPUS_DECODER) += libopusdec.o libopus.o \
@ -998,7 +993,7 @@ SKIPHEADERS-$(CONFIG_JNI) += ffjni.h
SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h
SKIPHEADERS-$(CONFIG_LIBVPX) += libvpx.h
SKIPHEADERS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc_common.h
SKIPHEADERS-$(CONFIG_MEDIACODEC) += mediacodecdec.h mediacodec_surface.h mediacodec_wrapper.h mediacodec_sw_buffer.h
SKIPHEADERS-$(CONFIG_MEDIACODEC) += mediacodecdec.h mediacodec_wrapper.h mediacodec_sw_buffer.h
SKIPHEADERS-$(CONFIG_NVENC) += nvenc.h
SKIPHEADERS-$(CONFIG_QSV) += qsv.h qsv_internal.h
SKIPHEADERS-$(CONFIG_QSVDEC) += qsvdec.h

View File

@ -77,13 +77,3 @@ wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
{
testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
}
wrap(avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt))
{
testneonclobbers(avcodec_send_packet, avctx, avpkt);
}
wrap(avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame))
{
testneonclobbers(avcodec_receive_frame, avctx, frame);
}

View File

@ -24,10 +24,9 @@
* Common code between the AC-3 encoder and decoder.
*/
#include "libavutil/common.h"
#include "avcodec.h"
#include "ac3.h"
#include "get_bits.h"
/**
* Starting frequency coefficient bin for each critical band.

View File

@ -623,7 +623,7 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
else
max_frame_size = s->max_coded_frame_size;
if ((ret = ff_alloc_packet2(avctx, avpkt, 4 * max_frame_size, 0)) < 0)
if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * max_frame_size, 0)) < 0)
return ret;
/* use verbatim mode for compression_level 0 */

View File

@ -72,7 +72,6 @@ void avcodec_register_all(void)
REGISTER_HWACCEL(H264_CUVID, h264_cuvid);
REGISTER_HWACCEL(H264_D3D11VA, h264_d3d11va);
REGISTER_HWACCEL(H264_DXVA2, h264_dxva2);
REGISTER_HWACCEL(H264_MEDIACODEC, h264_mediacodec);
REGISTER_HWACCEL(H264_MMAL, h264_mmal);
REGISTER_HWACCEL(H264_QSV, h264_qsv);
REGISTER_HWACCEL(H264_VAAPI, h264_vaapi);
@ -623,7 +622,7 @@ void avcodec_register_all(void)
/* external libraries, that shouldn't be used by default if one of the
* above is available */
REGISTER_ENCDEC (LIBOPENH264, libopenh264);
REGISTER_ENCODER(LIBOPENH264, libopenh264);
REGISTER_DECODER(H264_CUVID, h264_cuvid);
REGISTER_ENCODER(H264_NVENC, h264_nvenc);
REGISTER_ENCODER(H264_OMX, h264_omx);

View File

@ -77,13 +77,3 @@ wrap(avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
{
testneonclobbers(avcodec_encode_video2, avctx, avpkt, frame, got_packet_ptr);
}
wrap(avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt))
{
testneonclobbers(avcodec_send_packet, avctx, avpkt);
}
wrap(avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame))
{
testneonclobbers(avcodec_receive_frame, avctx, frame);
}

View File

@ -43,9 +43,7 @@
#include "version.h"
/**
* @defgroup libavc libavcodec
* Encoding/Decoding Library
*
* @defgroup libavc Encoding/Decoding Library
* @{
*
* @defgroup lavc_decoding Decoding
@ -1350,14 +1348,6 @@ typedef struct AVCPBProperties {
*/
enum AVPacketSideDataType {
AV_PKT_DATA_PALETTE,
/**
* The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format
* that the extradata buffer was changed and the receiving side should
* act upon it appropriately. The new extradata is embedded in the side
* data buffer and should be immediately used for processing the current
* frame or packet.
*/
AV_PKT_DATA_NEW_EXTRADATA,
/**
@ -3175,13 +3165,6 @@ typedef struct AVCodecContext {
#define FF_PROFILE_MPEG2_AAC_LOW 128
#define FF_PROFILE_MPEG2_AAC_HE 131
#define FF_PROFILE_DNXHD 0
#define FF_PROFILE_DNXHR_LB 1
#define FF_PROFILE_DNXHR_SQ 2
#define FF_PROFILE_DNXHR_HQ 3
#define FF_PROFILE_DNXHR_HQX 4
#define FF_PROFILE_DNXHR_444 5
#define FF_PROFILE_DTS 20
#define FF_PROFILE_DTS_ES 30
#define FF_PROFILE_DTS_96_24 40
@ -3206,10 +3189,8 @@ typedef struct AVCodecContext {
#define FF_PROFILE_H264_HIGH 100
#define FF_PROFILE_H264_HIGH_10 110
#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
#define FF_PROFILE_H264_MULTIVIEW_HIGH 118
#define FF_PROFILE_H264_HIGH_422 122
#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
#define FF_PROFILE_H264_STEREO_HIGH 128
#define FF_PROFILE_H264_HIGH_444 144
#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)

View File

@ -23,17 +23,17 @@
#include "libavutil/attributes.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "binkdata.h"
#include "binkdsp.h"
#include "blockdsp.h"
#include "get_bits.h"
#include "hpeldsp.h"
#include "internal.h"
#include "mathops.h"
#define BITSTREAM_READER_LE
#include "get_bits.h"
#define BINK_FLAG_ALPHA 0x00100000
#define BINK_FLAG_GRAY 0x00020000

View File

@ -29,15 +29,14 @@
*/
#include "libavutil/channel_layout.h"
#include "libavutil/intfloat.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "dct.h"
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "internal.h"
#include "dct.h"
#include "rdft.h"
#include "internal.h"
#include "wma_freqs.h"
#include "libavutil/intfloat.h"
static float quant_table[96];

View File

@ -261,7 +261,6 @@ static av_cold int init_decoder(AVCodecContext *avctx)
/* taking by default roll up to 2 */
ctx->mode = CCMODE_ROLLUP;
ctx->rollup = 2;
ctx->cursor_row = 10;
ret = ff_ass_subtitle_header(avctx, "Monospace",
ASS_DEFAULT_FONT_SIZE,
ASS_DEFAULT_COLOR,
@ -299,7 +298,7 @@ static void flush_decoder(AVCodecContext *avctx)
ctx->prev_cmd[1] = 0;
ctx->mode = CCMODE_ROLLUP;
ctx->rollup = 2;
ctx->cursor_row = 10;
ctx->cursor_row = 0;
ctx->cursor_column = 0;
ctx->cursor_font = 0;
ctx->cursor_color = 0;
@ -316,7 +315,7 @@ static void flush_decoder(AVCodecContext *avctx)
/**
* @param ctx closed caption context just to print log
*/
static void write_char(CCaptionSubContext *ctx, struct Screen *screen, char ch)
static int write_char(CCaptionSubContext *ctx, struct Screen *screen, char ch)
{
uint8_t col = ctx->cursor_column;
char *row = screen->characters[ctx->cursor_row];
@ -329,16 +328,16 @@ static void write_char(CCaptionSubContext *ctx, struct Screen *screen, char ch)
charset[col] = ctx->cursor_charset;
ctx->cursor_charset = CCSET_BASIC_AMERICAN;
if (ch) ctx->cursor_column++;
return;
return 0;
}
/* We have extra space at end only for null character */
else if (col == SCREEN_COLUMNS && ch == 0) {
row[col] = ch;
return;
return 0;
}
else {
av_log(ctx, AV_LOG_WARNING, "Data Ignored since exceeding screen width\n");
return;
return AVERROR_INVALIDDATA;
}
}
@ -436,24 +435,11 @@ static void roll_up(CCaptionSubContext *ctx)
static int capture_screen(CCaptionSubContext *ctx)
{
int i, j, tab = 0;
int i;
struct Screen *screen = ctx->screen + ctx->active_screen;
enum cc_font prev_font = CCFONT_REGULAR;
av_bprint_clear(&ctx->buffer);
for (i = 0; screen->row_used && i < SCREEN_ROWS; i++)
{
if (CHECK_FLAG(screen->row_used, i)) {
const char *row = screen->characters[i];
const char *charset = screen->charsets[i];
j = 0;
while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN)
j++;
if (!tab || j < tab)
tab = j;
}
}
for (i = 0; screen->row_used && i < SCREEN_ROWS; i++)
{
if (CHECK_FLAG(screen->row_used, i)) {
@ -461,17 +447,12 @@ static int capture_screen(CCaptionSubContext *ctx)
const char *font = screen->fonts[i];
const char *charset = screen->charsets[i];
const char *override;
int x, y, seen_char = 0;
j = 0;
int j = 0;
/* skip leading space */
while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN && j < tab)
while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN)
j++;
x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j);
y = ASS_DEFAULT_PLAYRESY * (0.1 + 0.0533 * i);
av_bprintf(&ctx->buffer, "{\\an7}{\\pos(%d,%d)}", x, y);
for (; j < SCREEN_COLUMNS; j++) {
const char *e_tag = "", *s_tag = "";
@ -506,14 +487,9 @@ static int capture_screen(CCaptionSubContext *ctx)
override = charset_overrides[(int)charset[j]][(int)row[j]];
if (override) {
av_bprintf(&ctx->buffer, "%s%s%s", e_tag, s_tag, override);
seen_char = 1;
} else if (row[j] == ' ' && !seen_char) {
av_bprintf(&ctx->buffer, "%s%s\\h", e_tag, s_tag);
} else {
av_bprintf(&ctx->buffer, "%s%s%c", e_tag, s_tag, row[j]);
seen_char = 1;
}
}
av_bprintf(&ctx->buffer, "\\N");
}
@ -737,12 +713,6 @@ static void process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint
/* Standard characters (always in pairs) */
handle_char(ctx, hi, lo, pts);
ctx->prev_cmd[0] = ctx->prev_cmd[1] = 0;
} else if (hi == 0x17 && lo >= 0x21 && lo <= 0x23) {
int i;
/* Tab offsets (spacing) */
for (i = 0; i < lo - 0x20; i++) {
handle_char(ctx, ' ', 0, pts);
}
} else {
/* Ignoring all other non data code */
ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);

View File

@ -513,7 +513,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
}
if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < expected) {
av_log(avctx, AV_LOG_ERROR, "Too many highpass coefficients\n");
av_log(avctx, AV_LOG_ERROR, "Too many highpass coefficents\n");
ret = AVERROR(EINVAL);
goto end;
}

View File

@ -665,7 +665,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "dnxhd",
.long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
.profiles = NULL_IF_CONFIG_SMALL(ff_dnxhd_profiles),
},
{
.id = AV_CODEC_ID_THP,
@ -1304,41 +1303,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("innoHeim/Rsupport Screen Capture Codec"),
.props = AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_MAGICYUV,
.type = AVMEDIA_TYPE_VIDEO,
.name = "magicyuv",
.long_name = NULL_IF_CONFIG_SMALL("MagicYUV video"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_TRUEMOTION2RT,
.type = AVMEDIA_TYPE_VIDEO,
.name = "truemotion2rt",
.long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0 Real Time"),
.props = AV_CODEC_PROP_LOSSY,
},
{
.id = AV_CODEC_ID_CFHD,
.type = AVMEDIA_TYPE_VIDEO,
.name = "cfhd",
.long_name = NULL_IF_CONFIG_SMALL("Cineform HD"),
.props = AV_CODEC_PROP_LOSSY,
},
{
.id = AV_CODEC_ID_SHEERVIDEO,
.type = AVMEDIA_TYPE_VIDEO,
.name = "sheervideo",
.long_name = NULL_IF_CONFIG_SMALL("BitJazz SheerVideo"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_YLC,
.type = AVMEDIA_TYPE_VIDEO,
.name = "ylc",
.long_name = NULL_IF_CONFIG_SMALL("YUY2 Lossless Codec"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
/* image codecs */
{
@ -1564,6 +1528,41 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSLESS,
.mime_types= MT("image/png"),
},
{
.id = AV_CODEC_ID_CFHD,
.type = AVMEDIA_TYPE_VIDEO,
.name = "cfhd",
.long_name = NULL_IF_CONFIG_SMALL("Cineform HD"),
.props = AV_CODEC_PROP_LOSSY,
},
{
.id = AV_CODEC_ID_TRUEMOTION2RT,
.type = AVMEDIA_TYPE_VIDEO,
.name = "truemotion2rt",
.long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0 Real Time"),
.props = AV_CODEC_PROP_LOSSY,
},
{
.id = AV_CODEC_ID_MAGICYUV,
.type = AVMEDIA_TYPE_VIDEO,
.name = "magicyuv",
.long_name = NULL_IF_CONFIG_SMALL("MagicYUV Lossless Video"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_SHEERVIDEO,
.type = AVMEDIA_TYPE_VIDEO,
.name = "sheervideo",
.long_name = NULL_IF_CONFIG_SMALL("BitJazz SheerVideo"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_YLC,
.type = AVMEDIA_TYPE_VIDEO,
.name = "ylc",
.long_name = NULL_IF_CONFIG_SMALL("YUY2 Lossless Codec"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
/* various PCM "codecs" */
{

View File

@ -83,7 +83,7 @@
#include <libcrystalhd/libcrystalhd_if.h>
#include "avcodec.h"
#include "h264dec.h"
#include "h264.h"
#include "internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"

View File

@ -1,247 +0,0 @@
/*
* Copyright (C) 2016 Open Broadcast Systems Ltd.
* Author 2016 Rostislav Pehlivanov <rpehlivanov@obe.tv>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dirac_vlc.h"
#define LUT_SIZE (1 << LUT_BITS)
#define RSIZE_BITS (CHAR_BIT*sizeof(residual))
#define CONVERT_TO_RESIDUE(a, b) \
(((residual)(a)) << (RSIZE_BITS - (b)))
#define INIT_RESIDUE(N) \
residual N = 0; \
av_unused int32_t N ## _bits = 0
#define SET_RESIDUE(N, I, B) \
N = CONVERT_TO_RESIDUE(I, B); \
N ## _bits = B
#define APPEND_RESIDUE(N, M) \
N |= M >> (N ## _bits); \
N ## _bits += (M ## _bits)
int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
int bytes, uint8_t *_dst, int coeffs)
{
int i, b, c_idx = 0;
int32_t *dst = (int32_t *)_dst;
DiracGolombLUT *future[4], *l = &lut_ctx[2*LUT_SIZE + buf[0]];
INIT_RESIDUE(res);
for (b = 1; b <= bytes; b++) {
future[0] = &lut_ctx[buf[b]];
future[1] = future[0] + 1*LUT_SIZE;
future[2] = future[0] + 2*LUT_SIZE;
future[3] = future[0] + 3*LUT_SIZE;
if ((c_idx + 1) > coeffs)
return c_idx;
/* res_bits is a hint for better branch prediction */
if (res_bits && l->sign) {
int32_t coeff = 1;
APPEND_RESIDUE(res, l->preamble);
for (i = 0; i < (res_bits >> 1) - 1; i++) {
coeff <<= 1;
coeff |= (res >> (RSIZE_BITS - 2*i - 2)) & 1;
}
dst[c_idx++] = l->sign * (coeff - 1);
res_bits = res = 0;
}
memcpy(&dst[c_idx], l->ready, LUT_BITS*sizeof(int32_t));
c_idx += l->ready_num;
APPEND_RESIDUE(res, l->leftover);
l = future[l->need_s ? 3 : !res_bits ? 2 : res_bits & 1];
}
return c_idx;
}
int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
int bytes, uint8_t *_dst, int coeffs)
{
int i, b, c_idx = 0;
int16_t *dst = (int16_t *)_dst;
DiracGolombLUT *future[4], *l = &lut_ctx[2*LUT_SIZE + buf[0]];
INIT_RESIDUE(res);
for (b = 1; b <= bytes; b++) {
future[0] = &lut_ctx[buf[b]];
future[1] = future[0] + 1*LUT_SIZE;
future[2] = future[0] + 2*LUT_SIZE;
future[3] = future[0] + 3*LUT_SIZE;
if ((c_idx + 1) > coeffs)
return c_idx;
if (res_bits && l->sign) {
int32_t coeff = 1;
APPEND_RESIDUE(res, l->preamble);
for (i = 0; i < (res_bits >> 1) - 1; i++) {
coeff <<= 1;
coeff |= (res >> (RSIZE_BITS - 2*i - 2)) & 1;
}
dst[c_idx++] = l->sign * (coeff - 1);
res_bits = res = 0;
}
for (i = 0; i < LUT_BITS; i++)
dst[c_idx + i] = l->ready[i];
c_idx += l->ready_num;
APPEND_RESIDUE(res, l->leftover);
l = future[l->need_s ? 3 : !res_bits ? 2 : res_bits & 1];
}
return c_idx;
}
/* Searches for golomb codes in a residue */
static inline void search_for_golomb(DiracGolombLUT *l, residual r, int bits)
{
int r_count = RSIZE_BITS - 1;
int bits_start, bits_tot = bits, need_sign = 0;
#define READ_BIT(N) (((N) >> (N ## _count--)) & 1)
while (1) {
int32_t coef = 1;
bits_start = (RSIZE_BITS - 1) - r_count;
while (1) {
if (!bits--)
goto leftover;
if (READ_BIT(r))
break;
coef <<= 1;
if (!bits--)
goto leftover;
coef |= READ_BIT(r);
}
l->ready[l->ready_num] = coef - 1;
if (l->ready[l->ready_num]) {
if (!bits--) {
need_sign = 1;
goto leftover;
}
l->ready[l->ready_num] *= READ_BIT(r) ? -1 : +1;
}
l->ready_num++;
if (!bits)
return;
}
leftover:
l->leftover = r << bits_start;
l->leftover_bits = bits_tot - bits_start;
l->need_s = need_sign;
}
/* Parity LUTs - even and odd bit end positions */
static void generate_parity_lut(DiracGolombLUT *lut, int even)
{
int idx;
for (idx = 0; idx < LUT_SIZE; idx++) {
DiracGolombLUT *l = &lut[idx];
int symbol_end_loc = -1;
uint32_t code;
int i;
INIT_RESIDUE(res);
SET_RESIDUE(res, idx, LUT_BITS);
for (i = 0; i < LUT_BITS; i++) {
const int cond = even ? (i & 1) : !(i & 1);
if (((res >> (RSIZE_BITS - i - 1)) & 1) && cond) {
symbol_end_loc = i + 2;
break;
}
}
if (symbol_end_loc < 0 || symbol_end_loc > LUT_BITS) {
l->preamble = 0;
l->preamble_bits = 0;
l->leftover_bits = LUT_BITS;
l->leftover = CONVERT_TO_RESIDUE(idx, l->leftover_bits);
if (even)
l->need_s = idx & 1;
continue;
}
/* Gets bits 0 through to (symbol_end_loc - 1) inclusive */
code = idx >> ((LUT_BITS - 1) - (symbol_end_loc - 1));
code &= ((1 << LUT_BITS) - 1) >> (LUT_BITS - symbol_end_loc);
l->preamble_bits = symbol_end_loc;
l->preamble = CONVERT_TO_RESIDUE(code, l->preamble_bits);
l->sign = ((l->preamble >> (RSIZE_BITS - l->preamble_bits)) & 1) ? -1 : +1;
search_for_golomb(l, res << symbol_end_loc, LUT_BITS - symbol_end_loc);
}
}
/* Reset (off == 0) and needs-one-more-bit (off == 1) LUTs */
static void generate_offset_lut(DiracGolombLUT *lut, int off)
{
int idx;
for (idx = 0; idx < LUT_SIZE; idx++) {
DiracGolombLUT *l = &lut[idx];
INIT_RESIDUE(res);
SET_RESIDUE(res, idx, LUT_BITS);
l->preamble = CONVERT_TO_RESIDUE(res >> (RSIZE_BITS - off), off);
l->preamble_bits = off;
l->sign = ((l->preamble >> (RSIZE_BITS - l->preamble_bits)) & 1) ? -1 : +1;
search_for_golomb(l, res << off, LUT_BITS - off);
}
}
av_cold int ff_dirac_golomb_reader_init(DiracGolombLUT **lut_ctx)
{
DiracGolombLUT *lut;
if (!(lut = av_calloc(4*LUT_SIZE, sizeof(DiracGolombLUT))))
return AVERROR(ENOMEM);
generate_parity_lut(&lut[0*LUT_SIZE], 0);
generate_parity_lut(&lut[1*LUT_SIZE], 1);
generate_offset_lut(&lut[2*LUT_SIZE], 0);
generate_offset_lut(&lut[3*LUT_SIZE], 1);
*lut_ctx = lut;
return 0;
}
av_cold void ff_dirac_golomb_reader_end(DiracGolombLUT **lut_ctx)
{
av_freep(lut_ctx);
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (C) 2016 Open Broadcast Systems Ltd.
* Author 2016 Rostislav Pehlivanov <rpehlivanov@obe.tv>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_DIRAC_VLC_H
#define AVCODEC_DIRAC_VLC_H
#include "libavutil/avutil.h"
/* Can be 32 bits wide for some performance gain on some machines, but it will
* incorrectly decode very long coefficients (usually only 1 or 2 per frame) */
typedef uint64_t residual;
#define LUT_BITS 8
/* Exactly 64 bytes */
typedef struct DiracGolombLUT {
residual preamble, leftover;
int32_t ready[LUT_BITS];
int32_t preamble_bits, leftover_bits, ready_num;
int8_t need_s, sign;
} DiracGolombLUT;
av_cold int ff_dirac_golomb_reader_init(DiracGolombLUT **lut_ctx);
int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
int bytes, uint8_t *dst, int coeffs);
int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
int bytes, uint8_t *_dst, int coeffs);
av_cold void ff_dirac_golomb_reader_end(DiracGolombLUT **lut_ctx);
#endif /* AVCODEC_DIRAC_VLC_H */

View File

@ -32,7 +32,6 @@
#include "internal.h"
#include "golomb.h"
#include "dirac_arith.h"
#include "dirac_vlc.h"
#include "mpeg12data.h"
#include "libavcodec/mpegvideo.h"
#include "mpegvideoencdsp.h"
@ -121,20 +120,11 @@ typedef struct Plane {
SubBand band[MAX_DWT_LEVELS][4];
} Plane;
/* Used by Low Delay and High Quality profiles */
typedef struct DiracSlice {
GetBitContext gb;
int slice_x;
int slice_y;
int bytes;
} DiracSlice;
typedef struct DiracContext {
AVCodecContext *avctx;
MpegvideoEncDSPContext mpvencdsp;
VideoDSPContext vdsp;
DiracDSPContext diracdsp;
DiracGolombLUT *reader_ctx;
DiracVersionInfo version;
GetBitContext gb;
AVDiracSeqHeader seq;
@ -171,13 +161,6 @@ typedef struct DiracContext {
unsigned num_x; /* number of horizontal slices */
unsigned num_y; /* number of vertical slices */
uint8_t *thread_buf; /* Per-thread buffer for coefficient storage */
int threads_num_buf; /* Current # of buffers allocated */
int thread_buf_size; /* Each thread has a buffer this size */
DiracSlice *slice_params_buf;
int slice_params_num_buf;
struct {
unsigned width;
unsigned height;
@ -387,11 +370,6 @@ static av_cold int dirac_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
s->frame_number = -1;
s->thread_buf = NULL;
s->threads_num_buf = -1;
s->thread_buf_size = -1;
ff_dirac_golomb_reader_init(&s->reader_ctx);
ff_diracdsp_init(&s->diracdsp);
ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
ff_videodsp_init(&s->vdsp, 8);
@ -421,29 +399,65 @@ static av_cold int dirac_decode_end(AVCodecContext *avctx)
DiracContext *s = avctx->priv_data;
int i;
ff_dirac_golomb_reader_end(&s->reader_ctx);
dirac_decode_flush(avctx);
for (i = 0; i < MAX_FRAMES; i++)
av_frame_free(&s->all_frames[i].avframe);
av_freep(&s->thread_buf);
av_freep(&s->slice_params_buf);
return 0;
}
#define SIGN_CTX(x) (CTX_SIGN_ZERO + ((x) > 0) - ((x) < 0))
static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset)
{
int coeff = dirac_get_se_golomb(gb);
const int sign = FFSIGN(coeff);
if (coeff)
coeff = sign*((sign * coeff * qfactor + qoffset) >> 2);
int sign, coeff;
uint32_t buf;
OPEN_READER(re, gb);
UPDATE_CACHE(re, gb);
buf = GET_CACHE(re, gb);
if (buf & 0x80000000) {
LAST_SKIP_BITS(re,gb,1);
CLOSE_READER(re, gb);
return 0;
}
if (buf & 0xAA800000) {
buf >>= 32 - 8;
SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
coeff = ff_interleaved_ue_golomb_vlc_code[buf];
} else {
unsigned ret = 1;
do {
buf >>= 32 - 8;
SKIP_BITS(re, gb,
FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
if (ff_interleaved_golomb_vlc_len[buf] != 9) {
ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
ret |= ff_interleaved_dirac_golomb_vlc_code[buf];
break;
}
ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
UPDATE_CACHE(re, gb);
buf = GET_CACHE(re, gb);
} while (ret<0x8000000U && BITS_AVAILABLE(re, gb));
coeff = ret - 1;
}
coeff = (coeff * qfactor + qoffset) >> 2;
sign = SHOW_SBITS(re, gb, 1);
LAST_SKIP_BITS(re, gb, 1);
coeff = (coeff ^ sign) - sign;
CLOSE_READER(re, gb);
return coeff;
}
#define SIGN_CTX(x) (CTX_SIGN_ZERO + ((x) > 0) - ((x) < 0))
#define UNPACK_ARITH(n, type) \
static inline void coeff_unpack_arith_##n(DiracArith *c, int qfactor, int qoffset, \
SubBand *b, type *buf, int x, int y) \
@ -513,7 +527,7 @@ static inline void codeblock(DiracContext *s, SubBand *b,
b->quant = quant;
}
if (b->quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
if (b->quant > 115) {
av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", b->quant);
b->quant = 0;
return;
@ -703,12 +717,12 @@ static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride: NULL;
int x, y;
if (quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
if (quant > 115) {
av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", quant);
return;
}
qfactor = ff_dirac_qscale_tab[quant];
qoffset = ff_dirac_qoffset_intra_tab[quant] + 2;
qfactor = ff_dirac_qscale_tab[quant & 0x7f];
qoffset = ff_dirac_qoffset_intra_tab[quant & 0x7f] + 2;
/* we have to constantly check for overread since the spec explicitly
requires this, with the meaning that all remaining coeffs are set to 0 */
if (get_bits_count(gb) >= bits_end)
@ -736,6 +750,15 @@ static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
}
}
/* Used by Low Delay and High Quality profiles */
typedef struct DiracSlice {
GetBitContext gb;
int slice_x;
int slice_y;
int bytes;
} DiracSlice;
/**
* Dirac Specification ->
* 13.5.2 Slices. slice(sx,sy)
@ -778,120 +801,52 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
return 0;
}
typedef struct SliceCoeffs {
int left;
int top;
int tot_h;
int tot_v;
int tot;
} SliceCoeffs;
static int subband_coeffs(DiracContext *s, int x, int y, int p,
SliceCoeffs c[MAX_DWT_LEVELS])
{
int level, coef = 0;
for (level = 0; level < s->wavelet_depth; level++) {
SliceCoeffs *o = &c[level];
SubBand *b = &s->plane[p].band[level][3]; /* orientation doens't matter */
o->top = b->height * y / s->num_y;
o->left = b->width * x / s->num_x;
o->tot_h = ((b->width * (x + 1)) / s->num_x) - o->left;
o->tot_v = ((b->height * (y + 1)) / s->num_y) - o->top;
o->tot = o->tot_h*o->tot_v;
coef += o->tot * (4 - !!level);
}
return coef;
}
/**
* VC-2 Specification ->
* 13.5.3 hq_slice(sx,sy)
*/
static int decode_hq_slice(DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
static int decode_hq_slice(AVCodecContext *avctx, void *arg)
{
int i, level, orientation, quant_idx;
int qfactor[MAX_DWT_LEVELS][4], qoffset[MAX_DWT_LEVELS][4];
int i, quant, level, orientation, quant_idx;
uint8_t quants[MAX_DWT_LEVELS][4];
DiracContext *s = avctx->priv_data;
DiracSlice *slice = arg;
GetBitContext *gb = &slice->gb;
SliceCoeffs coeffs_num[MAX_DWT_LEVELS];
skip_bits_long(gb, 8*s->highquality.prefix_bytes);
quant_idx = get_bits(gb, 8);
if (quant_idx > DIRAC_MAX_QUANT_INDEX) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid quantization index - %i\n", quant_idx);
return AVERROR_INVALIDDATA;
}
/* Slice quantization (slice_quantizers() in the specs) */
for (level = 0; level < s->wavelet_depth; level++) {
for (orientation = !!level; orientation < 4; orientation++) {
const int quant = FFMAX(quant_idx - s->lowdelay.quant[level][orientation], 0);
qfactor[level][orientation] = ff_dirac_qscale_tab[quant];
qoffset[level][orientation] = ff_dirac_qoffset_intra_tab[quant] + 2;
quant = FFMAX(quant_idx - s->lowdelay.quant[level][orientation], 0);
quants[level][orientation] = quant;
}
}
/* Luma + 2 Chroma planes */
for (i = 0; i < 3; i++) {
int coef_num, coef_par, off = 0;
int64_t length = s->highquality.size_scaler*get_bits(gb, 8);
int64_t bits_end = get_bits_count(gb) + 8*length;
const uint8_t *addr = align_get_bits(gb);
int64_t length = s->highquality.size_scaler * get_bits(gb, 8);
int64_t bits_left = 8 * length;
int64_t bits_end = get_bits_count(gb) + bits_left;
if (length*8 > get_bits_left(gb)) {
if (bits_end >= INT_MAX) {
av_log(s->avctx, AV_LOG_ERROR, "end too far away\n");
return AVERROR_INVALIDDATA;
}
coef_num = subband_coeffs(s, slice->slice_x, slice->slice_y, i, coeffs_num);
if (s->pshift)
coef_par = ff_dirac_golomb_read_32bit(s->reader_ctx, addr,
length, tmp_buf, coef_num);
else
coef_par = ff_dirac_golomb_read_16bit(s->reader_ctx, addr,
length, tmp_buf, coef_num);
if (coef_num > coef_par) {
const int start_b = coef_par * (1 << (s->pshift + 1));
const int end_b = coef_num * (1 << (s->pshift + 1));
memset(&tmp_buf[start_b], 0, end_b - start_b);
}
for (level = 0; level < s->wavelet_depth; level++) {
const SliceCoeffs *c = &coeffs_num[level];
for (orientation = !!level; orientation < 4; orientation++) {
const SubBand *b1 = &s->plane[i].band[level][orientation];
uint8_t *buf = b1->ibuf + c->top * b1->stride + (c->left << (s->pshift + 1));
/* Change to c->tot_h <= 4 for AVX2 dequantization */
const int qfunc = s->pshift + 2*(c->tot_h <= 2);
s->diracdsp.dequant_subband[qfunc](&tmp_buf[off], buf, b1->stride,
qfactor[level][orientation],
qoffset[level][orientation],
c->tot_v, c->tot_h);
off += c->tot << (s->pshift + 1);
decode_subband(s, gb, quants[level][orientation], slice->slice_x, slice->slice_y, bits_end,
&s->plane[i].band[level][orientation], NULL);
}
}
skip_bits_long(gb, bits_end - get_bits_count(gb));
}
return 0;
}
static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
{
int i;
DiracContext *s = avctx->priv_data;
DiracSlice *slices = ((DiracSlice *)arg) + s->num_x*jobnr;
uint8_t *thread_buf = &s->thread_buf[s->thread_buf_size*threadnr];
for (i = 0; i < s->num_x; i++)
decode_hq_slice(s, &slices[i], thread_buf);
return 0;
}
/**
* Dirac Specification ->
* 13.5.1 low_delay_transform_data()
@ -900,37 +855,14 @@ static int decode_lowdelay(DiracContext *s)
{
AVCodecContext *avctx = s->avctx;
int slice_x, slice_y, bufsize;
int64_t coef_buf_size, bytes = 0;
int64_t bytes = 0;
const uint8_t *buf;
DiracSlice *slices;
SliceCoeffs tmp[MAX_DWT_LEVELS];
int slice_num = 0;
if (s->slice_params_num_buf != (s->num_x * s->num_y)) {
s->slice_params_buf = av_realloc_f(s->thread_buf, s->num_x * s->num_y, sizeof(DiracSlice));
if (!s->slice_params_buf) {
av_log(s->avctx, AV_LOG_ERROR, "slice params buffer allocation failure\n");
return AVERROR(ENOMEM);
}
s->slice_params_num_buf = s->num_x * s->num_y;
}
slices = s->slice_params_buf;
/* 8 becacuse that's how much the golomb reader could overread junk data
* from another plane/slice at most, and 512 because SIMD */
coef_buf_size = subband_coeffs(s, s->num_x - 1, s->num_y - 1, 0, tmp) + 8;
coef_buf_size = (coef_buf_size << (1 + s->pshift)) + 512;
if (s->threads_num_buf != avctx->thread_count ||
s->thread_buf_size != coef_buf_size) {
s->threads_num_buf = avctx->thread_count;
s->thread_buf_size = coef_buf_size;
s->thread_buf = av_realloc_f(s->thread_buf, avctx->thread_count, s->thread_buf_size);
if (!s->thread_buf) {
av_log(s->avctx, AV_LOG_ERROR, "thread buffer allocation failure\n");
return AVERROR(ENOMEM);
}
}
slices = av_mallocz_array(s->num_x, s->num_y * sizeof(DiracSlice));
if (!slices)
return AVERROR(ENOMEM);
align_get_bits(&s->gb);
/*[DIRAC_STD] 13.5.2 Slices. slice(sx,sy) */
@ -947,8 +879,9 @@ static int decode_lowdelay(DiracContext *s)
if (bytes <= bufsize/8)
bytes += buf[bytes] * s->highquality.size_scaler + 1;
}
if (bytes >= INT_MAX || bytes*8 > bufsize) {
if (bytes >= INT_MAX) {
av_log(s->avctx, AV_LOG_ERROR, "too many bytes\n");
av_free(slices);
return AVERROR_INVALIDDATA;
}
@ -965,13 +898,8 @@ static int decode_lowdelay(DiracContext *s)
bufsize = 0;
}
}
if (s->num_x*s->num_y != slice_num) {
av_log(s->avctx, AV_LOG_ERROR, "too few slices\n");
return AVERROR_INVALIDDATA;
}
avctx->execute2(avctx, decode_hq_slice_row, slices, NULL, s->num_y);
avctx->execute(avctx, decode_hq_slice, slices, NULL, slice_num,
sizeof(DiracSlice));
} else {
for (slice_y = 0; bufsize > 0 && slice_y < s->num_y; slice_y++) {
for (slice_x = 0; bufsize > 0 && slice_x < s->num_x; slice_x++) {
@ -1005,7 +933,7 @@ static int decode_lowdelay(DiracContext *s)
intra_dc_prediction_8(&s->plane[2].band[0][0]);
}
}
av_free(slices);
return 0;
}
@ -1815,11 +1743,9 @@ static int dirac_decode_frame_internal(DiracContext *s)
if (s->low_delay) {
/* [DIRAC_STD] 13.5.1 low_delay_transform_data() */
if (!s->hq_picture) {
for (comp = 0; comp < 3; comp++) {
Plane *p = &s->plane[comp];
memset(p->idwt.buf, 0, p->idwt.stride * p->idwt.height);
}
for (comp = 0; comp < 3; comp++) {
Plane *p = &s->plane[comp];
memset(p->idwt.buf, 0, p->idwt.stride * p->idwt.height);
}
if (!s->zero_res) {
if ((ret = decode_lowdelay(s)) < 0)

View File

@ -189,27 +189,6 @@ static void add_rect_clamped_c(uint8_t *dst, const uint16_t *src, int stride,
}
}
#define DEQUANT_SUBBAND(PX) \
static void dequant_subband_ ## PX ## _c(uint8_t *src, uint8_t *dst, ptrdiff_t stride, \
const int qf, const int qs, int tot_v, int tot_h) \
{ \
int i, y; \
for (y = 0; y < tot_v; y++) { \
PX c, sign, *src_r = (PX *)src, *dst_r = (PX *)dst; \
for (i = 0; i < tot_h; i++) { \
c = *src_r++; \
sign = FFSIGN(c)*(!!c); \
c = (FFABS(c)*qf + qs) >> 2; \
*dst_r++ = c*sign; \
} \
src += tot_h << (sizeof(PX) >> 1); \
dst += stride; \
} \
}
DEQUANT_SUBBAND(int16_t)
DEQUANT_SUBBAND(int32_t)
#define PIXFUNC(PFX, WIDTH) \
c->PFX ## _dirac_pixels_tab[WIDTH>>4][0] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _c; \
c->PFX ## _dirac_pixels_tab[WIDTH>>4][1] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _l2_c; \
@ -235,9 +214,6 @@ av_cold void ff_diracdsp_init(DiracDSPContext *c)
c->biweight_dirac_pixels_tab[1] = biweight_dirac_pixels16_c;
c->biweight_dirac_pixels_tab[2] = biweight_dirac_pixels32_c;
c->dequant_subband[0] = c->dequant_subband[2] = dequant_subband_int16_t_c;
c->dequant_subband[1] = c->dequant_subband[3] = dequant_subband_int32_t_c;
PIXFUNC(put, 8);
PIXFUNC(put, 16);
PIXFUNC(put, 32);

View File

@ -22,7 +22,6 @@
#define AVCODEC_DIRACDSP_H
#include <stdint.h>
#include <stddef.h>
typedef void (*dirac_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int h);
typedef void (*dirac_biweight_func)(uint8_t *dst, const uint8_t *src, int stride, int log2_denom, int weightd, int weights, int h);
@ -47,9 +46,6 @@ typedef struct {
void (*add_rect_clamped)(uint8_t *dst/*align 16*/, const uint16_t *src/*align 16*/, int stride, const int16_t *idwt/*align 16*/, int idwt_stride, int width, int height/*mod 2*/);
void (*add_dirac_obmc[3])(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
/* 0-1: int16_t and int32_t asm/c, 2-3: int16 and int32_t, C only */
void (*dequant_subband[4])(uint8_t *src, uint8_t *dst, ptrdiff_t stride, const int qf, const int qs, int tot_v, int tot_h);
dirac_weight_func weight_dirac_pixels_tab[3];
dirac_biweight_func biweight_dirac_pixels_tab[3];
} DiracDSPContext;

View File

@ -38,6 +38,4 @@ extern const int32_t ff_dirac_qoffset_intra_tab[120];
/* Scaling offsets needed for quantization/dequantization, for inter frames */
extern const int ff_dirac_qoffset_inter_tab[122];
#define DIRAC_MAX_QUANT_INDEX (FF_ARRAY_ELEMS(ff_dirac_qscale_tab))
#endif /* AVCODEC_DIRACTAB_H */

View File

@ -22,6 +22,7 @@
#include "avcodec.h"
#include "dnxhddata.h"
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
/* The quantization tables below are in zigzag order! */
@ -1046,35 +1047,35 @@ const CIDEntry ff_dnxhd_cid_table[] = {
dnxhd_1235_dc_codes, dnxhd_1235_dc_bits,
dnxhd_1235_ac_codes, dnxhd_1235_ac_bits, dnxhd_1235_ac_info,
dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1235_run,
{ 0 }, { { 0 } }, { 57344, 255} },
{ 0 } },
{ 1271, DNXHD_VARIABLE, DNXHD_VARIABLE, DNXHD_VARIABLE, DNXHD_VARIABLE,
0, 6, DNXHD_VARIABLE, 4,
dnxhd_1241_luma_weight, dnxhd_1241_chroma_weight,
dnxhd_1235_dc_codes, dnxhd_1235_dc_bits,
dnxhd_1235_ac_codes, dnxhd_1235_ac_bits, dnxhd_1235_ac_info,
dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1235_run,
{ 0 }, { { 0 } }, { 28672, 255} },
{ 0 } },
{ 1272, DNXHD_VARIABLE, DNXHD_VARIABLE, DNXHD_VARIABLE, DNXHD_VARIABLE,
0, 4, 8, 4,
dnxhd_1238_luma_weight, dnxhd_1238_chroma_weight,
dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_info,
dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1238_run,
{ 0 }, { { 0 } }, { 28672, 255} },
{ 0 } },
{ 1273, DNXHD_VARIABLE, DNXHD_VARIABLE, DNXHD_VARIABLE, DNXHD_VARIABLE,
0, 4, 8, 3,
dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight,
dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_info,
dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
{ 0 }, { { 0 } }, { 18944, 255} },
{ 0 } },
{ 1274, DNXHD_VARIABLE, DNXHD_VARIABLE, DNXHD_VARIABLE, DNXHD_VARIABLE,
0, 4, 8, 3,
dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight,
dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_info,
dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
{ 0 }, { { 0 } }, { 5888, 255} },
{ 0 } },
};
int ff_dnxhd_get_cid_table(int cid)
@ -1102,38 +1103,17 @@ int avpriv_dnxhd_get_interlaced(int cid)
return ff_dnxhd_cid_table[i].flags & DNXHD_INTERLACED ? 1 : 0;
}
#if LIBAVCODEC_VERSION_MAJOR < 58
uint64_t avpriv_dnxhd_parse_header_prefix(const uint8_t *buf)
{
return ff_dnxhd_parse_header_prefix(buf);
}
#endif
static int dnxhd_find_hr_cid(AVCodecContext *avctx)
{
switch (avctx->profile) {
case FF_PROFILE_DNXHR_444:
return 1270;
case FF_PROFILE_DNXHR_HQX:
return 1271;
case FF_PROFILE_DNXHR_HQ:
return 1272;
case FF_PROFILE_DNXHR_SQ:
return 1273;
case FF_PROFILE_DNXHR_LB:
return 1274;
}
return 0;
uint64_t prefix = AV_RB32(buf);
prefix = (prefix << 16) | buf[4] << 8;
return ff_dnxhd_check_header_prefix(prefix);
}
int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth)
{
int i, j;
int mbs = avctx->bit_rate / 1000000;
if (avctx->profile != FF_PROFILE_DNXHD)
return dnxhd_find_hr_cid(avctx);
if (!mbs)
return 0;
for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) {

View File

@ -25,7 +25,6 @@
#include <stdint.h>
#include "avcodec.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
/** Additional profile info flags */
#define DNXHD_INTERLACED (1<<0)
@ -35,6 +34,8 @@
/** Frame headers, extra 0x00 added to end for parser */
#define DNXHD_HEADER_INITIAL 0x000002800100
#define DNXHD_HEADER_444 0x000002800200
#define DNXHD_HEADER_HR1 0x000002800300
#define DNXHD_HEADER_HR2 0x0000038C0300
/** Indicate that a CIDEntry value must be read in the bitstream */
#define DNXHD_VARIABLE 0
@ -56,7 +57,6 @@ typedef struct CIDEntry {
const uint8_t *run_bits, *run;
int bit_rates[5]; ///< Helper to choose variants, rounded to nearest 5Mb/s
AVRational frame_rates[5];
AVRational packet_scale;
} CIDEntry;
extern const CIDEntry ff_dnxhd_cid_table[];
@ -65,36 +65,17 @@ int ff_dnxhd_get_cid_table(int cid);
int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth);
void ff_dnxhd_print_profiles(AVCodecContext *avctx, int loglevel);
static av_always_inline uint64_t ff_dnxhd_check_header_prefix_hr(uint64_t prefix)
{
uint64_t data_offset = prefix >> 16;
if ((prefix & 0xFFFF0000FFFFLL) == 0x0300 &&
data_offset >= 0x0280 && data_offset <= 0x2170 &&
(data_offset & 3) == 0)
return prefix;
return 0;
}
static av_always_inline uint64_t ff_dnxhd_check_header_prefix(uint64_t prefix)
{
if (prefix == DNXHD_HEADER_INITIAL ||
prefix == DNXHD_HEADER_444 ||
ff_dnxhd_check_header_prefix_hr(prefix))
prefix == DNXHD_HEADER_HR1 ||
prefix == DNXHD_HEADER_HR2)
return prefix;
return 0;
}
static av_always_inline uint64_t ff_dnxhd_parse_header_prefix(const uint8_t *buf)
{
uint64_t prefix = AV_RB32(buf);
prefix = (prefix << 16) | buf[4] << 8;
return ff_dnxhd_check_header_prefix(prefix);
}
int avpriv_dnxhd_get_frame_size(int cid);
int avpriv_dnxhd_get_interlaced(int cid);
#if LIBAVCODEC_VERSION_MAJOR < 58
attribute_deprecated
uint64_t avpriv_dnxhd_parse_header_prefix(const uint8_t *buf);
#endif
#endif /* AVCODEC_DNXHDDATA_H */

View File

@ -33,7 +33,6 @@
#include "dnxhddata.h"
#include "idctdsp.h"
#include "internal.h"
#include "profiles.h"
#include "thread.h"
typedef struct RowContext {
@ -119,6 +118,11 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth)
av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", ff_dnxhd_cid_table[index].bit_depth, bitdepth);
return AVERROR_INVALIDDATA;
}
if (bitdepth > 10) {
avpriv_request_sample(ctx->avctx, "DNXHR 12-bit");
if (ctx->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)
return AVERROR_PATCHWELCOME;
}
ctx->cid_table = &ff_dnxhd_cid_table[index];
av_log(ctx->avctx, AV_LOG_VERBOSE, "Profile cid %d.\n", cid);
@ -129,7 +133,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth)
init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
ctx->cid_table->ac_bits, 1, 1,
ctx->cid_table->ac_codes, 2, 2, 0);
init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, bitdepth > 8 ? 14 : 12,
init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, bitdepth + 4,
ctx->cid_table->dc_bits, 1, 1,
ctx->cid_table->dc_codes, 1, 1, 0);
init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
@ -155,23 +159,6 @@ static av_cold int dnxhd_decode_init_thread_copy(AVCodecContext *avctx)
return 0;
}
static int dnxhd_get_profile(int cid)
{
switch(cid) {
case 1270:
return FF_PROFILE_DNXHR_444;
case 1271:
return FF_PROFILE_DNXHR_HQX;
case 1272:
return FF_PROFILE_DNXHR_HQ;
case 1273:
return FF_PROFILE_DNXHR_SQ;
case 1274:
return FF_PROFILE_DNXHR_LB;
}
return FF_PROFILE_DNXHD;
}
static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
const uint8_t *buf, int buf_size,
int first_field)
@ -185,7 +172,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
return AVERROR_INVALIDDATA;
}
header_prefix = ff_dnxhd_parse_header_prefix(buf);
header_prefix = avpriv_dnxhd_parse_header_prefix(buf);
if (header_prefix == 0) {
av_log(ctx->avctx, AV_LOG_ERROR,
"unknown header 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
@ -217,9 +204,6 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
}
cid = AV_RB32(buf + 0x28);
ctx->avctx->profile = dnxhd_get_profile(cid);
if ((ret = dnxhd_init_vlc(ctx, cid, bitdepth)) < 0)
return ret;
if (ctx->mbaff && ctx->cid_table->cid != 1260)
@ -291,7 +275,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
ctx->bit_depth, ctx->mbaff, ctx->act);
// Newer format supports variable mb_scan_index sizes
if (ctx->mb_height > 68 && ff_dnxhd_check_header_prefix_hr(header_prefix)) {
if (header_prefix == DNXHD_HEADER_HR2) {
ctx->data_offset = 0x170 + (ctx->mb_height << 2);
} else {
if (ctx->mb_height > 68 ||
@ -708,5 +692,4 @@ AVCodec ff_dnxhd_decoder = {
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(dnxhd_decode_init_thread_copy),
.profiles = NULL_IF_CONFIG_SMALL(ff_dnxhd_profiles),
};

View File

@ -34,7 +34,6 @@
#include "internal.h"
#include "mpegvideo.h"
#include "pixblockdsp.h"
#include "profiles.h"
#include "dnxhdenc.h"
// The largest value that will not lead to overflow for 10-bit samples.
@ -49,21 +48,6 @@ static const AVOption options[] = {
{ "ibias", "intra quant bias",
offsetof(DNXHDEncContext, intra_quant_bias), AV_OPT_TYPE_INT,
{ .i64 = 0 }, INT_MIN, INT_MAX, VE },
{ "profile", NULL, offsetof(DNXHDEncContext, profile), AV_OPT_TYPE_INT,
{ .i64 = FF_PROFILE_DNXHD },
FF_PROFILE_DNXHD, FF_PROFILE_DNXHR_444, VE, "profile" },
{ "dnxhd", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHD },
0, 0, VE, "profile" },
{ "dnxhr_444", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_444 },
0, 0, VE, "profile" },
{ "dnxhr_hqx", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_HQX },
0, 0, VE, "profile" },
{ "dnxhr_hq", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_HQ },
0, 0, VE, "profile" },
{ "dnxhr_sq", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_SQ },
0, 0, VE, "profile" },
{ "dnxhr_lb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_LB },
0, 0, VE, "profile" },
{ NULL }
};
@ -286,13 +270,13 @@ fail:
static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx)
{
FF_ALLOCZ_ARRAY_OR_GOTO(ctx->m.avctx, ctx->mb_rc, (ctx->m.avctx->qmax + 1),
ctx->m.mb_num * sizeof(RCEntry), fail);
FF_ALLOCZ_ARRAY_OR_GOTO(ctx->m.avctx, ctx->mb_rc, (ctx->m.avctx->qmax + 1), 8160 * sizeof(RCEntry), fail);
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
FF_ALLOCZ_ARRAY_OR_GOTO(ctx->m.avctx, ctx->mb_cmp,
ctx->m.mb_num, sizeof(RCCMPEntry), fail);
ctx->frame_bits = (ctx->coding_unit_size -
ctx->data_offset - 4 - ctx->min_padding) * 8;
ctx->frame_bits = (ctx->cid_table->coding_unit_size -
640 - 4 - ctx->min_padding) * 8;
ctx->qscale = 1;
ctx->lambda = 2 << LAMBDA_FRAC_BITS; // qscale 2
return 0;
@ -300,12 +284,6 @@ fail:
return AVERROR(ENOMEM);
}
static int dnxhd_get_hr_frame_size(const CIDEntry* profile, int mb_num)
{
int result = mb_num * profile->packet_scale.num / profile->packet_scale.den;
result = (result + 2048) / 4096 * 4096;
return FFMAX(result, 8192);
}
static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
{
DNXHDEncContext *ctx = avctx->priv_data;
@ -324,14 +302,6 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
if (ctx->profile == FF_PROFILE_DNXHR_HQX ||
ctx->profile == FF_PROFILE_DNXHR_HQX) {
avpriv_report_missing_feature(avctx,
"dnxhr_444 or dnxhr_hqx profile");
return AVERROR_PATCHWELCOME;
}
avctx->profile = ctx->profile;
ctx->cid = ff_dnxhd_find_cid(avctx, bit_depth);
if (!ctx->cid) {
av_log(avctx, AV_LOG_ERROR,
@ -341,15 +311,6 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
}
av_log(avctx, AV_LOG_DEBUG, "cid %d\n", ctx->cid);
if (ctx->cid >= 1270 && ctx->cid <= 1274)
avctx->codec_tag = MKTAG('A','V','d','h');
if (avctx->width < 256 || avctx->height < 120) {
av_log(avctx, AV_LOG_ERROR,
"Input dimensions too small, input must be at least 256x120\n");
return AVERROR(EINVAL);
}
index = ff_dnxhd_get_cid_table(ctx->cid);
av_assert0(index >= 0);
@ -393,20 +354,6 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
ctx->m.mb_num = ctx->m.mb_height * ctx->m.mb_width;
if (ctx->cid_table->frame_size == DNXHD_VARIABLE) {
ctx->frame_size = dnxhd_get_hr_frame_size(ctx->cid_table,
ctx->m.mb_num);
ctx->coding_unit_size = ctx->frame_size;
} else {
ctx->frame_size = ctx->cid_table->frame_size;
ctx->coding_unit_size = ctx->cid_table->coding_unit_size;
}
if (ctx->m.mb_height > 68)
ctx->data_offset = 0x170 + (ctx->m.mb_height << 2);
else
ctx->data_offset = 0x280;
#if FF_API_QUANT_BIAS
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
@ -467,16 +414,11 @@ fail: // for FF_ALLOCZ_OR_GOTO
static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf)
{
DNXHDEncContext *ctx = avctx->priv_data;
static const uint8_t header_prefix[5] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
memset(buf, 0, ctx->data_offset);
// * write prefix */
AV_WB16(buf + 0x02, ctx->data_offset);
if (ctx->cid >= 1270 && ctx->cid <= 1274)
buf[4] = 0x03;
else
buf[4] = 0x01;
memset(buf, 0, 640);
memcpy(buf, header_prefix, 5);
buf[5] = ctx->interlaced ? ctx->cur_field + 2 : 0x01;
buf[6] = 0x80; // crc flag off
buf[7] = 0xa0; // reserved
@ -630,7 +572,7 @@ void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y)
pdsp->get_pixels(ctx->blocks[2], ptr_u, ctx->m.uvlinesize);
pdsp->get_pixels(ctx->blocks[3], ptr_v, ctx->m.uvlinesize);
if (mb_y + 1 == ctx->m.mb_height && (ctx->m.avctx->height % 16) != 0) {
if (mb_y + 1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) {
if (ctx->interlaced) {
ctx->get_pixels_8x4_sym(ctx->blocks[4],
ptr_y + ctx->dct_y_offset,
@ -718,8 +660,8 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg,
ssd += dnxhd_ssd_block(block, src_block);
}
}
ctx->mb_rc[(qscale * ctx->m.mb_num) + mb].ssd = ssd;
ctx->mb_rc[(qscale * ctx->m.mb_num) + mb].bits = ac_bits + dc_bits + 12 +
ctx->mb_rc[qscale][mb].ssd = ssd;
ctx->mb_rc[qscale][mb].bits = ac_bits + dc_bits + 12 +
8 * ctx->vlc_bits[0];
}
return 0;
@ -731,7 +673,7 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg,
DNXHDEncContext *ctx = avctx->priv_data;
int mb_y = jobnr, mb_x;
ctx = ctx->thread[threadnr];
init_put_bits(&ctx->m.pb, (uint8_t *)arg + ctx->data_offset + ctx->slice_offs[jobnr],
init_put_bits(&ctx->m.pb, (uint8_t *)arg + 640 + ctx->slice_offs[jobnr],
ctx->slice_size[jobnr]);
ctx->m.last_dc[0] =
@ -797,7 +739,7 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
int sum;
int varc;
if (!partial_last_row && mb_x * 16 <= avctx->width - 16 && (avctx->width % 16) == 0) {
if (!partial_last_row && mb_x * 16 <= avctx->width - 16) {
sum = ctx->m.mpvencdsp.pix_sum(pix, ctx->m.linesize);
varc = ctx->m.mpvencdsp.pix_norm1(pix, ctx->m.linesize);
} else {
@ -875,20 +817,17 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
unsigned min = UINT_MAX;
int qscale = 1;
int mb = y * ctx->m.mb_width + x;
int rc = 0;
for (q = 1; q < avctx->qmax; q++) {
int i = (q*ctx->m.mb_num) + mb;
unsigned score = ctx->mb_rc[i].bits * lambda +
((unsigned) ctx->mb_rc[i].ssd << LAMBDA_FRAC_BITS);
unsigned score = ctx->mb_rc[q][mb].bits * lambda +
((unsigned) ctx->mb_rc[q][mb].ssd << LAMBDA_FRAC_BITS);
if (score < min) {
min = score;
qscale = q;
rc = i;
}
}
bits += ctx->mb_rc[rc].bits;
bits += ctx->mb_rc[qscale][mb].bits;
ctx->mb_qscale[mb] = qscale;
ctx->mb_bits[mb] = ctx->mb_rc[rc].bits;
ctx->mb_bits[mb] = ctx->mb_rc[qscale][mb].bits;
}
bits = (bits + 31) & ~31; // padding
if (bits > ctx->frame_bits)
@ -949,7 +888,7 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
NULL, NULL, ctx->m.mb_height);
for (y = 0; y < ctx->m.mb_height; y++) {
for (x = 0; x < ctx->m.mb_width; x++)
bits += ctx->mb_rc[(qscale*ctx->m.mb_num) + (y*ctx->m.mb_width+x)].bits;
bits += ctx->mb_rc[qscale][y*ctx->m.mb_width+x].bits;
bits = (bits+31)&~31; // padding
if (bits > ctx->frame_bits)
break;
@ -1058,18 +997,17 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx)
for (y = 0; y < ctx->m.mb_height; y++) {
for (x = 0; x < ctx->m.mb_width; x++) {
int mb = y * ctx->m.mb_width + x;
int rc = (ctx->qscale * ctx->m.mb_num ) + mb;
int delta_bits;
ctx->mb_qscale[mb] = ctx->qscale;
ctx->mb_bits[mb] = ctx->mb_rc[rc].bits;
max_bits += ctx->mb_rc[rc].bits;
ctx->mb_bits[mb] = ctx->mb_rc[ctx->qscale][mb].bits;
max_bits += ctx->mb_rc[ctx->qscale][mb].bits;
if (!RC_VARIANCE) {
delta_bits = ctx->mb_rc[rc].bits -
ctx->mb_rc[rc + ctx->m.mb_num].bits;
delta_bits = ctx->mb_rc[ctx->qscale][mb].bits -
ctx->mb_rc[ctx->qscale + 1][mb].bits;
ctx->mb_cmp[mb].mb = mb;
ctx->mb_cmp[mb].value =
delta_bits ? ((ctx->mb_rc[rc].ssd -
ctx->mb_rc[rc + ctx->m.mb_num].ssd) * 100) /
delta_bits ? ((ctx->mb_rc[ctx->qscale][mb].ssd -
ctx->mb_rc[ctx->qscale + 1][mb].ssd) * 100) /
delta_bits
: INT_MIN; // avoid increasing qscale
}
@ -1083,11 +1021,10 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx)
radix_sort(ctx->mb_cmp, ctx->m.mb_num);
for (x = 0; x < ctx->m.mb_num && max_bits > ctx->frame_bits; x++) {
int mb = ctx->mb_cmp[x].mb;
int rc = (ctx->qscale * ctx->m.mb_num ) + mb;
max_bits -= ctx->mb_rc[rc].bits -
ctx->mb_rc[rc + ctx->m.mb_num].bits;
max_bits -= ctx->mb_rc[ctx->qscale][mb].bits -
ctx->mb_rc[ctx->qscale + 1][mb].bits;
ctx->mb_qscale[mb] = ctx->qscale + 1;
ctx->mb_bits[mb] = ctx->mb_rc[rc + ctx->m.mb_num].bits;
ctx->mb_bits[mb] = ctx->mb_rc[ctx->qscale + 1][mb].bits;
}
}
return 0;
@ -1120,7 +1057,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
int offset, i, ret;
uint8_t *buf;
if ((ret = ff_alloc_packet2(avctx, pkt, ctx->frame_size, 0)) < 0)
if ((ret = ff_alloc_packet2(avctx, pkt, ctx->cid_table->frame_size, 0)) < 0)
return ret;
buf = pkt->data;
@ -1156,16 +1093,16 @@ encode_coding_unit:
avctx->execute2(avctx, dnxhd_encode_thread, buf, NULL, ctx->m.mb_height);
av_assert1(ctx->data_offset + offset + 4 <= ctx->coding_unit_size);
memset(buf + ctx->data_offset + offset, 0,
ctx->coding_unit_size - 4 - offset - ctx->data_offset);
av_assert1(640 + offset + 4 <= ctx->cid_table->coding_unit_size);
memset(buf + 640 + offset, 0,
ctx->cid_table->coding_unit_size - 4 - offset - 640);
AV_WB32(buf + ctx->coding_unit_size - 4, 0x600DC0DE); // EOF
AV_WB32(buf + ctx->cid_table->coding_unit_size - 4, 0x600DC0DE); // EOF
if (ctx->interlaced && first_field) {
first_field = 0;
ctx->cur_field ^= 1;
buf += ctx->coding_unit_size;
buf += ctx->cid_table->coding_unit_size;
goto encode_coding_unit;
}
@ -1233,5 +1170,4 @@ AVCodec ff_dnxhd_encoder = {
},
.priv_class = &dnxhd_class,
.defaults = dnxhd_defaults,
.profiles = NULL_IF_CONFIG_SMALL(ff_dnxhd_profiles),
};

View File

@ -45,7 +45,6 @@ typedef struct DNXHDEncContext {
MpegEncContext m; ///< Used for quantization dsp functions
int cid;
int profile;
const CIDEntry *cid_table;
uint8_t *msip; ///< Macroblock Scan Indexes Payload
uint32_t *slice_size;
@ -59,10 +58,6 @@ typedef struct DNXHDEncContext {
unsigned dct_uv_offset;
unsigned block_width_l2;
int frame_size;
int coding_unit_size;
int data_offset;
int interlaced;
int cur_field;
@ -94,7 +89,7 @@ typedef struct DNXHDEncContext {
uint8_t *mb_qscale;
RCCMPEntry *mb_cmp;
RCEntry *mb_rc;
RCEntry (*mb_rc)[8160];
void (*get_pixels_8x4_sym)(int16_t * /* align 16 */,
const uint8_t *, ptrdiff_t);

View File

@ -44,6 +44,7 @@
#include "avcodec.h"
#include "dv.h"
#include "dvdata.h"
#include "get_bits.h"
#include "internal.h"
#include "put_bits.h"
#include "simple_idct.h"

View File

@ -29,8 +29,8 @@
#include "avcodec.h"
#include "dv_profile.h"
#include "get_bits.h"
#include "me_cmp.h"
#include "vlc.h"
typedef struct DVwork_chunk {
uint16_t buf_offset;

View File

@ -18,14 +18,8 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <string.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
/* Parser (mostly) copied from dvdsub.c */

View File

@ -27,7 +27,6 @@
#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
@ -36,7 +35,6 @@
#include "dv_tablegen.h"
#include "fdctdsp.h"
#include "internal.h"
#include "mathops.h"
#include "me_cmp.h"
#include "pixblockdsp.h"
#include "put_bits.h"

View File

@ -22,15 +22,14 @@
#include <inttypes.h>
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "bytestream.h"
#include "get_bits.h"
#include "internal.h"
#include "unary.h"
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size,

View File

@ -22,9 +22,8 @@
#include "libavutil/avassert.h"
#include "h264dec.h"
#include "h264.h"
#include "h264data.h"
#include "h264_ps.h"
#include "mpegutils.h"
// The headers above may include w32threads.h, which uses the original

View File

@ -28,13 +28,13 @@
* http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TGQ
*/
#define BITSTREAM_READER_LE
#include "aandcttab.h"
#include "avcodec.h"
#include "bytestream.h"
#include "eaidct.h"
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "bytestream.h"
#include "idctdsp.h"
#include "aandcttab.h"
#include "eaidct.h"
#include "internal.h"
typedef struct TgqContext {

View File

@ -28,13 +28,12 @@
* http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TGV
*/
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#define EA_PREAMBLE_SIZE 8
#define kVGT_TAG MKTAG('k', 'V', 'G', 'T')

View File

@ -19,11 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#define BITSTREAM_READER_LE
#include "get_bits.h"
typedef union MacroBlock {
uint16_t pixels[4];
uint32_t pixels32[2];

View File

@ -21,9 +21,8 @@
#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "internal.h"

View File

@ -129,8 +129,6 @@ typedef struct EXRContext {
EXRTileAttribute tile_attr; /* header data attribute of tile */
int is_tile; /* 0 if scanline, 1 if tile */
int is_luma;/* 1 if there is an Y plane */
GetByteContext gb;
const uint8_t *buf;
int buf_size;
@ -751,9 +749,6 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
uint16_t *tmp = (uint16_t *)td->tmp;
uint8_t *out;
int ret, i, j;
int pixel_half_size;/* 1 for half, 2 for float and uint32 */
EXRChannel *channel;
int tmp_offset;
if (!td->bitmap)
td->bitmap = av_malloc(BITMAP_SIZE);
@ -786,38 +781,24 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
ptr = tmp;
for (i = 0; i < s->nb_channels; i++) {
channel = &s->channels[i];
EXRChannel *channel = &s->channels[i];
int size = channel->pixel_type;
if (channel->pixel_type == EXR_HALF)
pixel_half_size = 1;
else
pixel_half_size = 2;
for (j = 0; j < pixel_half_size; j++)
wav_decode(ptr + j, td->xsize, pixel_half_size, td->ysize,
td->xsize * pixel_half_size, maxval);
ptr += td->xsize * td->ysize * pixel_half_size;
for (j = 0; j < size; j++)
wav_decode(ptr + j, td->xsize, size, td->ysize,
td->xsize * size, maxval);
ptr += td->xsize * td->ysize * size;
}
apply_lut(td->lut, tmp, dsize / sizeof(uint16_t));
out = td->uncompressed_data;
for (i = 0; i < td->ysize; i++) {
tmp_offset = 0;
for (i = 0; i < td->ysize; i++)
for (j = 0; j < s->nb_channels; j++) {
uint16_t *in;
EXRChannel *channel = &s->channels[j];
if (channel->pixel_type == EXR_HALF)
pixel_half_size = 1;
else
pixel_half_size = 2;
in = tmp + tmp_offset * td->xsize * td->ysize + i * td->xsize * pixel_half_size;
tmp_offset += pixel_half_size;
memcpy(out, in, td->xsize * 2 * pixel_half_size);
out += td->xsize * 2 * pixel_half_size;
uint16_t *in = tmp + j * td->xsize * td->ysize + i * td->xsize;
memcpy(out, in, td->xsize * 2);
out += td->xsize * 2;
}
}
return 0;
}
@ -944,74 +925,74 @@ static void unpack_3(const uint8_t b[3], uint16_t s[16])
static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size,
int uncompressed_size, EXRThreadData *td) {
const int8_t *sr = src;
int stay_to_uncompress = compressed_size;
int nb_b44_block_w, nb_b44_block_h;
int index_tl_x, index_tl_y, index_out, index_tmp;
uint16_t tmp_buffer[16]; /* B44 use 4x4 half float pixel */
int stayToUncompress = compressed_size;
int nbB44BlockW, nbB44BlockH;
int indexHgX, indexHgY, indexOut, indexTmp;
uint16_t tmpBuffer[16]; /* B44 use 4x4 half float pixel */
int c, iY, iX, y, x;
int target_channel_offset = 0;
/* calc B44 block count */
nb_b44_block_w = td->xsize / 4;
nbB44BlockW = td->xsize / 4;
if ((td->xsize % 4) != 0)
nb_b44_block_w++;
nbB44BlockW++;
nb_b44_block_h = td->ysize / 4;
nbB44BlockH = td->ysize / 4;
if ((td->ysize % 4) != 0)
nb_b44_block_h++;
nbB44BlockH++;
for (c = 0; c < s->nb_channels; c++) {
if (s->channels[c].pixel_type == EXR_HALF) {/* B44 only compress half float data */
for (iY = 0; iY < nb_b44_block_h; iY++) {
for (iX = 0; iX < nb_b44_block_w; iX++) {/* For each B44 block */
if (stay_to_uncompress < 3) {
av_log(s, AV_LOG_ERROR, "Not enough data for B44A block: %d", stay_to_uncompress);
for (iY = 0; iY < nbB44BlockH; iY++) {
for (iX = 0; iX < nbB44BlockW; iX++) {/* For each B44 block */
if (stayToUncompress < 3) {
av_log(s, AV_LOG_ERROR, "Not enough data for B44A block: %d", stayToUncompress);
return AVERROR_INVALIDDATA;
}
if (src[compressed_size - stay_to_uncompress + 2] == 0xfc) { /* B44A block */
unpack_3(sr, tmp_buffer);
if (src[compressed_size - stayToUncompress + 2] == 0xfc) { /* B44A block */
unpack_3(sr, tmpBuffer);
sr += 3;
stay_to_uncompress -= 3;
stayToUncompress -= 3;
} else {/* B44 Block */
if (stay_to_uncompress < 14) {
av_log(s, AV_LOG_ERROR, "Not enough data for B44 block: %d", stay_to_uncompress);
if (stayToUncompress < 14) {
av_log(s, AV_LOG_ERROR, "Not enough data for B44 block: %d", stayToUncompress);
return AVERROR_INVALIDDATA;
}
unpack_14(sr, tmp_buffer);
unpack_14(sr, tmpBuffer);
sr += 14;
stay_to_uncompress -= 14;
stayToUncompress -= 14;
}
/* copy data to uncompress buffer (B44 block can exceed target resolution)*/
index_tl_x = iX * 4;
index_tl_y = iY * 4;
indexHgX = iX * 4;
indexHgY = iY * 4;
for (y = index_tl_y; y < FFMIN(index_tl_y + 4, td->ysize); y++) {
for (x = index_tl_x; x < FFMIN(index_tl_x + 4, td->xsize); x++) {
index_out = target_channel_offset * td->xsize + y * td->channel_line_size + 2 * x;
index_tmp = (y-index_tl_y) * 4 + (x-index_tl_x);
td->uncompressed_data[index_out] = tmp_buffer[index_tmp] & 0xff;
td->uncompressed_data[index_out + 1] = tmp_buffer[index_tmp] >> 8;
for (y = indexHgY; y < FFMIN(indexHgY + 4, td->ysize); y++) {
for (x = indexHgX; x < FFMIN(indexHgX + 4, td->xsize); x++) {
indexOut = target_channel_offset * td->xsize + y * td->channel_line_size + 2 * x;
indexTmp = (y-indexHgY) * 4 + (x-indexHgX);
td->uncompressed_data[indexOut] = tmpBuffer[indexTmp] & 0xff;
td->uncompressed_data[indexOut + 1] = tmpBuffer[indexTmp] >> 8;
}
}
}
}
target_channel_offset += 2;
} else {/* Float or UINT 32 channel */
if (stay_to_uncompress < td->ysize * td->xsize * 4) {
av_log(s, AV_LOG_ERROR, "Not enough data for uncompress channel: %d", stay_to_uncompress);
if (stayToUncompress < td->ysize * td->xsize * 4) {
av_log(s, AV_LOG_ERROR, "Not enough data for uncompress channel: %d", stayToUncompress);
return AVERROR_INVALIDDATA;
}
for (y = 0; y < td->ysize; y++) {
index_out = target_channel_offset * td->xsize + y * td->channel_line_size;
memcpy(&td->uncompressed_data[index_out], sr, td->xsize * 4);
indexOut = target_channel_offset * td->xsize + y * td->channel_line_size;
memcpy(&td->uncompressed_data[indexOut], sr, td->xsize * 4);
sr += td->xsize * 4;
}
target_channel_offset += 4;
stay_to_uncompress -= td->ysize * td->xsize * 4;
stayToUncompress -= td->ysize * td->xsize * 4;
}
}
@ -1035,7 +1016,6 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
int axmax = (avctx->width - (s->xmax + 1)) * 2 * s->desc->nb_components; /* nb pixel to add at the right of the datawindow */
int bxmin = s->xmin * 2 * s->desc->nb_components; /* nb pixel to add at the left of the datawindow */
int i, x, buf_size = s->buf_size;
int c, rgb_channel_count;
float one_gamma = 1.0f / s->gamma;
avpriv_trc_function trc_func = avpriv_get_trc_function_from_trc(s->apply_trc_type);
int ret;
@ -1145,15 +1125,9 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
src = td->uncompressed_data;
}
if (!s->is_luma) {
channel_buffer[0] = src + td->xsize * s->channel_offsets[0];
channel_buffer[1] = src + td->xsize * s->channel_offsets[1];
channel_buffer[2] = src + td->xsize * s->channel_offsets[2];
rgb_channel_count = 3;
} else { /* put y data in the first channel_buffer */
channel_buffer[0] = src + td->xsize * s->channel_offsets[1];
rgb_channel_count = 1;
}
channel_buffer[0] = src + td->xsize * s->channel_offsets[0];
channel_buffer[1] = src + td->xsize * s->channel_offsets[1];
channel_buffer[2] = src + td->xsize * s->channel_offsets[2];
if (s->channel_offsets[3] >= 0)
channel_buffer[3] = src + td->xsize * s->channel_offsets[3];
@ -1162,13 +1136,11 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
for (i = 0;
i < td->ysize; i++, ptr += p->linesize[0]) {
const uint8_t * a;
const uint8_t *rgb[3];
for (c = 0; c < rgb_channel_count; c++){
rgb[c] = channel_buffer[c];
}
const uint8_t *r, *g, *b, *a;
r = channel_buffer[0];
g = channel_buffer[1];
b = channel_buffer[2];
if (channel_buffer[3])
a = channel_buffer[3];
@ -1183,27 +1155,37 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
if (trc_func) {
for (x = 0; x < td->xsize; x++) {
union av_intfloat32 t;
t.i = bytestream_get_le32(&r);
t.f = trc_func(t.f);
*ptr_x++ = exr_flt2uint(t.i);
for (c = 0; c < rgb_channel_count; c++) {
t.i = bytestream_get_le32(&rgb[c]);
t.f = trc_func(t.f);
*ptr_x++ = exr_flt2uint(t.i);
}
t.i = bytestream_get_le32(&g);
t.f = trc_func(t.f);
*ptr_x++ = exr_flt2uint(t.i);
t.i = bytestream_get_le32(&b);
t.f = trc_func(t.f);
*ptr_x++ = exr_flt2uint(t.i);
if (channel_buffer[3])
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&a));
}
} else {
for (x = 0; x < td->xsize; x++) {
union av_intfloat32 t;
int c;
t.i = bytestream_get_le32(&r);
if (t.f > 0.0f) /* avoid negative values */
t.f = powf(t.f, one_gamma);
*ptr_x++ = exr_flt2uint(t.i);
for (c = 0; c < rgb_channel_count; c++) {
t.i = bytestream_get_le32(&rgb[c]);
if (t.f > 0.0f) /* avoid negative values */
t.f = powf(t.f, one_gamma);
*ptr_x++ = exr_flt2uint(t.i);
}
t.i = bytestream_get_le32(&g);
if (t.f > 0.0f)
t.f = powf(t.f, one_gamma);
*ptr_x++ = exr_flt2uint(t.i);
t.i = bytestream_get_le32(&b);
if (t.f > 0.0f)
t.f = powf(t.f, one_gamma);
*ptr_x++ = exr_flt2uint(t.i);
if (channel_buffer[3])
*ptr_x++ = exr_flt2uint(bytestream_get_le32(&a));
}
@ -1211,11 +1193,9 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
} else {
// 16-bit
for (x = 0; x < td->xsize; x++) {
int c;
for (c = 0; c < rgb_channel_count; c++) {
*ptr_x++ = s->gamma_table[bytestream_get_le16(&rgb[c])];
}
*ptr_x++ = s->gamma_table[bytestream_get_le16(&r)];
*ptr_x++ = s->gamma_table[bytestream_get_le16(&g)];
*ptr_x++ = s->gamma_table[bytestream_get_le16(&b)];
if (channel_buffer[3])
*ptr_x++ = exr_halflt2uint(bytestream_get_le16(&a));
}
@ -1299,7 +1279,6 @@ static int decode_header(EXRContext *s)
s->tile_attr.xSize = -1;
s->tile_attr.ySize = -1;
s->is_tile = 0;
s->is_luma = 0;
if (bytestream2_get_bytes_left(&s->gb) < 10) {
av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
@ -1367,27 +1346,21 @@ static int decode_header(EXRContext *s)
if (layer_match) { /* only search channel if the layer match is valid */
if (!strcmp(ch_gb.buffer, "R") ||
!strcmp(ch_gb.buffer, "X") ||
!strcmp(ch_gb.buffer, "U")) {
!strcmp(ch_gb.buffer, "U"))
channel_index = 0;
s->is_luma = 0;
} else if (!strcmp(ch_gb.buffer, "G") ||
!strcmp(ch_gb.buffer, "V")) {
else if (!strcmp(ch_gb.buffer, "G") ||
!strcmp(ch_gb.buffer, "Y") ||
!strcmp(ch_gb.buffer, "V"))
channel_index = 1;
s->is_luma = 0;
} else if (!strcmp(ch_gb.buffer, "Y")) {
channel_index = 1;
s->is_luma = 1;
} else if (!strcmp(ch_gb.buffer, "B") ||
!strcmp(ch_gb.buffer, "Z") ||
!strcmp(ch_gb.buffer, "W")){
channel_index = 2;
s->is_luma = 0;
} else if (!strcmp(ch_gb.buffer, "A")) {
else if (!strcmp(ch_gb.buffer, "B") ||
!strcmp(ch_gb.buffer, "Z") ||
!strcmp(ch_gb.buffer, "W"))
channel_index = 2;
else if (!strcmp(ch_gb.buffer, "A"))
channel_index = 3;
} else {
else
av_log(s->avctx, AV_LOG_WARNING,
"Unsupported channel %.256s.\n", ch_gb.buffer);
}
}
/* skip until you get a 0 */
@ -1410,7 +1383,6 @@ static int decode_header(EXRContext *s)
bytestream2_skip(&ch_gb, 4);
xsub = bytestream2_get_le32(&ch_gb);
ysub = bytestream2_get_le32(&ch_gb);
if (xsub != 1 || ysub != 1) {
avpriv_report_missing_feature(s->avctx,
"Subsampling %dx%d",
@ -1445,18 +1417,16 @@ static int decode_header(EXRContext *s)
/* Check if all channels are set with an offset or if the channels
* are causing an overflow */
if (!s->is_luma){/* if we expected to have at least 3 channels */
if (FFMIN3(s->channel_offsets[0],
s->channel_offsets[1],
s->channel_offsets[2]) < 0) {
if (s->channel_offsets[0] < 0)
av_log(s->avctx, AV_LOG_ERROR, "Missing red channel.\n");
if (s->channel_offsets[1] < 0)
av_log(s->avctx, AV_LOG_ERROR, "Missing green channel.\n");
if (s->channel_offsets[2] < 0)
av_log(s->avctx, AV_LOG_ERROR, "Missing blue channel.\n");
return AVERROR_INVALIDDATA;
}
if (FFMIN3(s->channel_offsets[0],
s->channel_offsets[1],
s->channel_offsets[2]) < 0) {
if (s->channel_offsets[0] < 0)
av_log(s->avctx, AV_LOG_ERROR, "Missing red channel.\n");
if (s->channel_offsets[1] < 0)
av_log(s->avctx, AV_LOG_ERROR, "Missing green channel.\n");
if (s->channel_offsets[2] < 0)
av_log(s->avctx, AV_LOG_ERROR, "Missing blue channel.\n");
return AVERROR_INVALIDDATA;
}
// skip one last byte and update main gb
@ -1607,19 +1577,10 @@ static int decode_frame(AVCodecContext *avctx, void *data,
switch (s->pixel_type) {
case EXR_FLOAT:
case EXR_HALF:
if (s->channel_offsets[3] >= 0) {
if (!s->is_luma) {
avctx->pix_fmt = AV_PIX_FMT_RGBA64;
} else {
avctx->pix_fmt = AV_PIX_FMT_YA16;
}
} else {
if (!s->is_luma) {
avctx->pix_fmt = AV_PIX_FMT_RGB48;
} else {
avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
}
if (s->channel_offsets[3] >= 0)
avctx->pix_fmt = AV_PIX_FMT_RGBA64;
else
avctx->pix_fmt = AV_PIX_FMT_RGB48;
break;
case EXR_UINT:
avpriv_request_sample(avctx, "32-bit unsigned int");

View File

@ -31,42 +31,25 @@
#include "jni.h"
#include "ffjni.h"
static JavaVM *java_vm;
static pthread_key_t current_env;
static pthread_once_t once = PTHREAD_ONCE_INIT;
static JavaVM *java_vm = NULL;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static void jni_detach_env(void *data)
{
if (java_vm) {
(*java_vm)->DetachCurrentThread(java_vm);
}
}
static void jni_create_pthread_key(void)
{
pthread_key_create(&current_env, jni_detach_env);
}
JNIEnv *ff_jni_get_env(void *log_ctx)
JNIEnv *ff_jni_attach_env(int *attached, void *log_ctx)
{
int ret = 0;
JNIEnv *env = NULL;
*attached = 0;
pthread_mutex_lock(&lock);
if (java_vm == NULL) {
java_vm = av_jni_get_java_vm(log_ctx);
}
pthread_mutex_unlock(&lock);
if (!java_vm) {
av_log(log_ctx, AV_LOG_ERROR, "No Java virtual machine has been registered\n");
goto done;
}
pthread_once(&once, jni_create_pthread_key);
if ((env = pthread_getspecific(current_env)) != NULL) {
goto done;
return NULL;
}
ret = (*java_vm)->GetEnv(java_vm, (void **)&env, JNI_VERSION_1_6);
@ -76,7 +59,7 @@ JNIEnv *ff_jni_get_env(void *log_ctx)
av_log(log_ctx, AV_LOG_ERROR, "Failed to attach the JNI environment to the current thread\n");
env = NULL;
} else {
pthread_setspecific(current_env, env);
*attached = 1;
}
break;
case JNI_OK:
@ -89,11 +72,19 @@ JNIEnv *ff_jni_get_env(void *log_ctx)
break;
}
done:
pthread_mutex_unlock(&lock);
return env;
}
int ff_jni_detach_env(void *log_ctx)
{
if (java_vm == NULL) {
av_log(log_ctx, AV_LOG_ERROR, "No Java virtual machine has been registered\n");
return AVERROR(EINVAL);
}
return (*java_vm)->DetachCurrentThread(java_vm);
}
char *ff_jni_jstring_to_utf_chars(JNIEnv *env, jstring string, void *log_ctx)
{
char *ret = NULL;

View File

@ -26,10 +26,7 @@
#include <jni.h>
/*
* Attach permanently a JNI environment to the current thread and retrieve it.
*
* If successfully attached, the JNI environment will automatically be detached
* at thread destruction.
* Attach a JNI environment to the current thread.
*
* @param attached pointer to an integer that will be set to 1 if the
* environment has been attached to the current thread or 0 if it is
@ -37,7 +34,15 @@
* @param log_ctx context used for logging, can be NULL
* @return the JNI environment on success, NULL otherwise
*/
JNIEnv *ff_jni_get_env(void *log_ctx);
JNIEnv *ff_jni_attach_env(int *attached, void *log_ctx);
/*
* Detach the JNI environment from the current thread.
*
* @param log_ctx context used for logging, can be NULL
* @return 0 on success, < 0 otherwise
*/
int ff_jni_detach_env(void *log_ctx);
/*
* Convert a jstring to its utf characters equivalent.

View File

@ -36,6 +36,7 @@
#include "avcodec.h"
#include "internal.h"
#include "rangecoder.h"
#include "golomb.h"
#include "mathops.h"
#include "ffv1.h"

View File

@ -881,7 +881,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
if ((ret = ff_ffv1_common_init(avctx)) < 0)
return ret;
if (avctx->extradata_size > 0 && (ret = read_extra_header(f)) < 0)
if (avctx->extradata && (ret = read_extra_header(f)) < 0)
return ret;
if ((ret = ff_ffv1_init_slice_contexts(f)) < 0)

View File

@ -24,7 +24,6 @@
#include "libavutil/intmath.h"
#include "libavutil/md5.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "bswapdsp.h"
#include "put_bits.h"

View File

@ -25,18 +25,17 @@
* G.723.1 compatible decoder
*/
#define BITSTREAM_READER_LE
#include "libavutil/channel_layout.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#define BITSTREAM_READER_LE
#include "acelp_vectors.h"
#include "avcodec.h"
#include "get_bits.h"
#include "acelp_vectors.h"
#include "celp_filters.h"
#include "celp_math.h"
#include "get_bits.h"
#include "internal.h"
#include "g723_1.h"
#include "internal.h"
#define CNG_RANDOM_SEED 12345

View File

@ -26,13 +26,6 @@ const uint16_t ff_gsm_long_term_gain_tab[4] = {
3277, 11469, 21299, 32767
};
const uint8_t ff_gsm_requant_tab[4][8] = {
{ 0 },
{ 0, 7 },
{ 0, 2, 5, 7 },
{ 0, 1, 2, 3, 4, 5, 6, 7 }
};
const int16_t ff_gsm_dequant_tab[64][8] = {
{ -28, -20, -12, -4, 4, 12, 20, 28},
{ -56, -40, -24, -8, 8, 24, 40, 56},

View File

@ -38,7 +38,6 @@ typedef struct GSMContext {
} GSMContext;
extern const uint16_t ff_gsm_long_term_gain_tab[4];
extern const uint8_t ff_gsm_requant_tab[4][8];
extern const int16_t ff_gsm_dequant_tab[64][8];
extern const int* const ff_gsm_apcm_bits[][4];

View File

@ -28,6 +28,13 @@
#include "gsm.h"
#include "gsmdec_data.h"
static const int requant_tab[4][8] = {
{ 0 },
{ 0, 7 },
{ 0, 2, 5, 7 },
{ 0, 1, 2, 3, 4, 5, 6, 7 }
};
static void apcm_dequant_add(GetBitContext *gb, int16_t *dst, const int *frame_bits)
{
int i, val;
@ -35,7 +42,7 @@ static void apcm_dequant_add(GetBitContext *gb, int16_t *dst, const int *frame_b
const int16_t *tab = ff_gsm_dequant_tab[maxidx];
for (i = 0; i < 13; i++) {
val = get_bits(gb, frame_bits[i]);
dst[3 * i] += tab[ff_gsm_requant_tab[frame_bits[i]][val]];
dst[3*i] += tab[requant_tab[frame_bits[i]][val]];
}
}

View File

@ -35,6 +35,7 @@
#include "h263data.h"
#include "mathops.h"
#include "mpegutils.h"
#include "unary.h"
#include "flv.h"
#include "mpeg4video.h"

View File

@ -40,12 +40,10 @@
#include "error_resilience.h"
#include "avcodec.h"
#include "h264.h"
#include "h264dec.h"
#include "h2645_parse.h"
#include "h264data.h"
#include "h264chroma.h"
#include "h264_mvpred.h"
#include "h264_ps.h"
#include "golomb.h"
#include "mathops.h"
#include "me_cmp.h"
@ -310,6 +308,7 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
h->backup_width = -1;
h->backup_height = -1;
h->backup_pix_fmt = AV_PIX_FMT_NONE;
h->current_sps_id = -1;
h->cur_chroma_format_idc = -1;
h->picture_structure = PICT_FRAME;
@ -406,13 +405,15 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
return AVERROR_UNKNOWN;
}
if (avctx->ticks_per_frame == 1) {
if(h->avctx->time_base.den < INT_MAX/2) {
h->avctx->time_base.den *= 2;
} else
h->avctx->time_base.num /= 2;
if (avctx->codec_id == AV_CODEC_ID_H264) {
if (avctx->ticks_per_frame == 1) {
if(h->avctx->time_base.den < INT_MAX/2) {
h->avctx->time_base.den *= 2;
} else
h->avctx->time_base.num /= 2;
}
avctx->ticks_per_frame = 2;
}
avctx->ticks_per_frame = 2;
if (avctx->extradata_size > 0 && avctx->extradata) {
ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
@ -497,6 +498,153 @@ static void decode_postinit(H264Context *h, int setup_finished)
return;
}
cur->f->interlaced_frame = 0;
cur->f->repeat_pict = 0;
/* Signal interlacing information externally. */
/* Prioritize picture timing SEI information over used
* decoding process if it exists. */
if (sps->pic_struct_present_flag) {
H264SEIPictureTiming *pt = &h->sei.picture_timing;
switch (pt->pic_struct) {
case SEI_PIC_STRUCT_FRAME:
break;
case SEI_PIC_STRUCT_TOP_FIELD:
case SEI_PIC_STRUCT_BOTTOM_FIELD:
cur->f->interlaced_frame = 1;
break;
case SEI_PIC_STRUCT_TOP_BOTTOM:
case SEI_PIC_STRUCT_BOTTOM_TOP:
if (FIELD_OR_MBAFF_PICTURE(h))
cur->f->interlaced_frame = 1;
else
// try to flag soft telecine progressive
cur->f->interlaced_frame = h->prev_interlaced_frame;
break;
case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
/* Signal the possibility of telecined film externally
* (pic_struct 5,6). From these hints, let the applications
* decide if they apply deinterlacing. */
cur->f->repeat_pict = 1;
break;
case SEI_PIC_STRUCT_FRAME_DOUBLING:
cur->f->repeat_pict = 2;
break;
case SEI_PIC_STRUCT_FRAME_TRIPLING:
cur->f->repeat_pict = 4;
break;
}
if ((pt->ct_type & 3) &&
pt->pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP)
cur->f->interlaced_frame = (pt->ct_type & (1 << 1)) != 0;
} else {
/* Derive interlacing flag from used decoding process. */
cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h);
}
h->prev_interlaced_frame = cur->f->interlaced_frame;
if (cur->field_poc[0] != cur->field_poc[1]) {
/* Derive top_field_first from field pocs. */
cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1];
} else {
if (sps->pic_struct_present_flag) {
/* Use picture timing SEI information. Even if it is a
* information of a past frame, better than nothing. */
if (h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM ||
h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)
cur->f->top_field_first = 1;
else
cur->f->top_field_first = 0;
} else if (cur->f->interlaced_frame) {
/* Default to top field first when pic_struct_present_flag
* is not set but interlaced frame detected */
cur->f->top_field_first = 1;
} else {
/* Most likely progressive */
cur->f->top_field_first = 0;
}
}
if (h->sei.frame_packing.present &&
h->sei.frame_packing.frame_packing_arrangement_type <= 6 &&
h->sei.frame_packing.content_interpretation_type > 0 &&
h->sei.frame_packing.content_interpretation_type < 3) {
H264SEIFramePacking *fp = &h->sei.frame_packing;
AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f);
if (stereo) {
switch (fp->frame_packing_arrangement_type) {
case 0:
stereo->type = AV_STEREO3D_CHECKERBOARD;
break;
case 1:
stereo->type = AV_STEREO3D_COLUMNS;
break;
case 2:
stereo->type = AV_STEREO3D_LINES;
break;
case 3:
if (fp->quincunx_sampling_flag)
stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
else
stereo->type = AV_STEREO3D_SIDEBYSIDE;
break;
case 4:
stereo->type = AV_STEREO3D_TOPBOTTOM;
break;
case 5:
stereo->type = AV_STEREO3D_FRAMESEQUENCE;
break;
case 6:
stereo->type = AV_STEREO3D_2D;
break;
}
if (fp->content_interpretation_type == 2)
stereo->flags = AV_STEREO3D_FLAG_INVERT;
}
}
if (h->sei.display_orientation.present &&
(h->sei.display_orientation.anticlockwise_rotation ||
h->sei.display_orientation.hflip ||
h->sei.display_orientation.vflip)) {
H264SEIDisplayOrientation *o = &h->sei.display_orientation;
double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16);
AVFrameSideData *rotation = av_frame_new_side_data(cur->f,
AV_FRAME_DATA_DISPLAYMATRIX,
sizeof(int32_t) * 9);
if (rotation) {
av_display_rotation_set((int32_t *)rotation->data, angle);
av_display_matrix_flip((int32_t *)rotation->data,
o->hflip, o->vflip);
}
}
if (h->sei.afd.present) {
AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD,
sizeof(uint8_t));
if (sd) {
*sd->data = h->sei.afd.active_format_description;
h->sei.afd.present = 0;
}
}
if (h->sei.a53_caption.a53_caption) {
H264SEIA53Caption *a53 = &h->sei.a53_caption;
AVFrameSideData *sd = av_frame_new_side_data(cur->f,
AV_FRAME_DATA_A53_CC,
a53->a53_caption_size);
if (sd)
memcpy(sd->data, a53->a53_caption, a53->a53_caption_size);
av_freep(&a53->a53_caption);
a53->a53_caption_size = 0;
h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
}
cur->mmco_reset = h->mmco_reset;
h->mmco_reset = 0;
@ -629,6 +777,8 @@ void ff_h264_flush_change(H264Context *h)
h->frame_recovered = 0;
h->current_slice = 0;
h->mmco_reset = 1;
for (i = 0; i < h->nb_slice_ctx; i++)
h->slice_ctx[i].list_count = 0;
}
/* forget old pics after a seek */
@ -672,13 +822,13 @@ static int get_last_needed_nal(H264Context *h)
* which splits NALs strangely if so, when frame threading we
* can't start the next thread until we've read all of them */
switch (nal->type) {
case H264_NAL_SPS:
case H264_NAL_PPS:
case NAL_SPS:
case NAL_PPS:
nals_needed = i;
break;
case H264_NAL_DPA:
case H264_NAL_IDR_SLICE:
case H264_NAL_SLICE:
case NAL_DPA:
case NAL_IDR_SLICE:
case NAL_SLICE:
ret = init_get_bits8(&gb, nal->data + 1, (nal->size - 1));
if (ret < 0)
return ret;
@ -766,7 +916,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
int err;
if (avctx->skip_frame >= AVDISCARD_NONREF &&
nal->ref_idc == 0 && nal->type != H264_NAL_SEI)
nal->ref_idc == 0 && nal->type != NAL_SEI)
continue;
again:
@ -776,13 +926,19 @@ again:
err = 0;
switch (nal->type) {
case H264_NAL_IDR_SLICE:
case NAL_IDR_SLICE:
if ((nal->data[1] & 0xFC) == 0x98) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
h->next_outputed_poc = INT_MIN;
ret = -1;
goto end;
}
if (nal->type != NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
ret = -1;
goto end;
}
if(!idr_cleared) {
if (h->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {
av_log(h, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
@ -793,10 +949,13 @@ again:
}
idr_cleared = 1;
h->has_recovery_point = 1;
case H264_NAL_SLICE:
case NAL_SLICE:
sl->gb = nal->gb;
if ( nals_needed >= i
|| (!(avctx->active_thread_type & FF_THREAD_FRAME) && !context_count))
h->au_pps_id = -1;
if ((err = ff_h264_decode_slice_header(h, sl, nal)))
if ((err = ff_h264_decode_slice_header(h, sl)))
break;
if (h->sei.recovery_point.recovery_frame_cnt >= 0) {
@ -814,16 +973,16 @@ again:
}
}
h->cur_pic_ptr->f->key_frame |= (nal->type == H264_NAL_IDR_SLICE);
h->cur_pic_ptr->f->key_frame |= (nal->type == NAL_IDR_SLICE);
if (nal->type == H264_NAL_IDR_SLICE ||
if (nal->type == NAL_IDR_SLICE ||
(h->recovery_frame == h->poc.frame_num && nal->ref_idc)) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
}
// If we have an IDR, all frames after it in decoded order are
// "recovered".
if (nal->type == H264_NAL_IDR_SLICE)
if (nal->type == NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
#if 1
h->cur_pic_ptr->recovered |= h->frame_recovered;
@ -866,12 +1025,12 @@ again:
context_count++;
}
break;
case H264_NAL_DPA:
case H264_NAL_DPB:
case H264_NAL_DPC:
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
avpriv_request_sample(avctx, "data partitioning");
break;
case H264_NAL_SEI:
case NAL_SEI:
ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
h->has_recovery_point = h->has_recovery_point || h->sei.recovery_point.recovery_frame_cnt != -1;
if (avctx->debug & FF_DEBUG_GREEN_MD)
@ -884,7 +1043,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
case H264_NAL_SPS: {
case NAL_SPS: {
GetBitContext tmp_gb = nal->gb;
if (ff_h264_decode_seq_parameter_set(&tmp_gb, avctx, &h->ps, 0) >= 0)
break;
@ -896,18 +1055,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps, 1);
break;
}
case H264_NAL_PPS:
case NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, avctx, &h->ps,
nal->size_bits);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
case H264_NAL_AUD:
case H264_NAL_END_SEQUENCE:
case H264_NAL_END_STREAM:
case H264_NAL_FILLER_DATA:
case H264_NAL_SPS_EXT:
case H264_NAL_AUXILIARY_SLICE:
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
case NAL_FF_IGNORE:
break;
default:
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
@ -1149,7 +1310,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
if (buf_index < 0)
return AVERROR_INVALIDDATA;
if (!h->cur_pic_ptr && h->nal_unit_type == H264_NAL_END_SEQUENCE) {
if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
av_assert0(buf_index <= buf_size);
goto out;
}

File diff suppressed because it is too large Load Diff

View File

@ -258,7 +258,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
int extract_length = 0;
int skip_trailing_zeros = 1;
if (buf == next_avc) {
if (buf >= next_avc) {
int i;
for (i = 0; i < nal_length_size; i++)
extract_length = (extract_length << 8) | buf[i];
@ -271,9 +271,6 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
}
next_avc = buf + extract_length;
} else {
if (buf > next_avc)
av_log(logctx, AV_LOG_WARNING, "Exceeded next NALFF position, re-syncing.\n");
/* search start code */
while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
++buf;
@ -293,7 +290,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
buf += 3;
length -= 3;
extract_length = FFMIN(length, next_avc - buf);
extract_length = length;
if (buf >= next_avc) {
/* skip to the start of the next NAL */

View File

@ -37,9 +37,10 @@
#include "cabac_functions.h"
#include "internal.h"
#include "avcodec.h"
#include "h264dec.h"
#include "h264.h"
#include "h264data.h"
#include "h264_mvpred.h"
#include "golomb.h"
#include "mpegutils.h"
#if ARCH_X86
@ -2358,7 +2359,7 @@ decode_intra_mb:
}
}
if (sl->top_type && !IS_8x8DCT(sl->top_type)){
uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040;
AV_WN32A(&nnz_cache[4+8* 0], top_empty);
AV_WN32A(&nnz_cache[4+8* 5], top_empty);
AV_WN32A(&nnz_cache[4+8*10], top_empty);
@ -2403,8 +2404,8 @@ decode_intra_mb:
if (sl->qscale < 0) sl->qscale += max_qp + 1;
else sl->qscale -= max_qp + 1;
}
sl->chroma_qp[0] = get_chroma_qp(h->ps.pps, 0, sl->qscale);
sl->chroma_qp[1] = get_chroma_qp(h->ps.pps, 1, sl->qscale);
sl->chroma_qp[0] = get_chroma_qp(h, 0, sl->qscale);
sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale);
}else
sl->last_qscale_diff=0;

View File

@ -30,7 +30,7 @@
#include "internal.h"
#include "avcodec.h"
#include "h264dec.h"
#include "h264.h"
#include "h264_mvpred.h"
#include "h264data.h"
#include "golomb.h"
@ -1123,8 +1123,8 @@ decode_intra_mb:
}
}
sl->chroma_qp[0] = get_chroma_qp(h->ps.pps, 0, sl->qscale);
sl->chroma_qp[1] = get_chroma_qp(h->ps.pps, 1, sl->qscale);
sl->chroma_qp[0] = get_chroma_qp(h, 0, sl->qscale);
sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale);
if ((ret = decode_luma_residual(h, sl, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 0)) < 0 ) {
return -1;

View File

@ -27,8 +27,7 @@
#include "internal.h"
#include "avcodec.h"
#include "h264dec.h"
#include "h264_ps.h"
#include "h264.h"
#include "mpegutils.h"
#include "rectangle.h"
#include "thread.h"

View File

@ -29,8 +29,7 @@
#include "libavutil/intreadwrite.h"
#include "internal.h"
#include "avcodec.h"
#include "h264dec.h"
#include "h264_ps.h"
#include "h264.h"
#include "mathops.h"
#include "mpegutils.h"
#include "rectangle.h"
@ -259,9 +258,9 @@ static av_always_inline void h264_filter_mb_fast_internal(const H264Context *h,
int qp = h->cur_pic.qscale_table[mb_xy];
int qp0 = h->cur_pic.qscale_table[mb_xy - 1];
int qp1 = h->cur_pic.qscale_table[sl->top_mb_xy];
int qpc = get_chroma_qp(h->ps.pps, 0, qp);
int qpc0 = get_chroma_qp(h->ps.pps, 0, qp0);
int qpc1 = get_chroma_qp(h->ps.pps, 0, qp1);
int qpc = get_chroma_qp( h, 0, qp );
int qpc0 = get_chroma_qp( h, 0, qp0 );
int qpc1 = get_chroma_qp( h, 0, qp1 );
qp0 = (qp + qp0 + 1) >> 1;
qp1 = (qp + qp1 + 1) >> 1;
qpc0 = (qpc + qpc0 + 1) >> 1;
@ -530,8 +529,8 @@ static av_always_inline void filter_mb_dir(const H264Context *h, H264SliceContex
ff_tlog(h->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
{ int i; for (i = 0; i < 4; i++) ff_tlog(h->avctx, " bS[%d]:%d", i, bS[i]); ff_tlog(h->avctx, "\n"); }
filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, a, b, h, 0 );
chroma_qp_avg[0] = (sl->chroma_qp[0] + get_chroma_qp(h->ps.pps, 0, h->cur_pic.qscale_table[mbn_xy]) + 1) >> 1;
chroma_qp_avg[1] = (sl->chroma_qp[1] + get_chroma_qp(h->ps.pps, 1, h->cur_pic.qscale_table[mbn_xy]) + 1) >> 1;
chroma_qp_avg[0] = (sl->chroma_qp[0] + get_chroma_qp(h, 0, h->cur_pic.qscale_table[mbn_xy]) + 1) >> 1;
chroma_qp_avg[1] = (sl->chroma_qp[1] + get_chroma_qp(h, 1, h->cur_pic.qscale_table[mbn_xy]) + 1) >> 1;
if (chroma) {
if (chroma444) {
filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0);
@ -595,8 +594,8 @@ static av_always_inline void filter_mb_dir(const H264Context *h, H264SliceContex
//ff_tlog(h->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], h->cur_pic.qscale_table[mbn_xy]);
ff_tlog(h->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
//{ int i; for (i = 0; i < 4; i++) ff_tlog(h->avctx, " bS[%d]:%d", i, bS[i]); ff_tlog(h->avctx, "\n"); }
chroma_qp_avg[0] = (sl->chroma_qp[0] + get_chroma_qp(h->ps.pps, 0, h->cur_pic.qscale_table[mbm_xy]) + 1) >> 1;
chroma_qp_avg[1] = (sl->chroma_qp[1] + get_chroma_qp(h->ps.pps, 1, h->cur_pic.qscale_table[mbm_xy]) + 1) >> 1;
chroma_qp_avg[0] = (sl->chroma_qp[0] + get_chroma_qp(h, 0, h->cur_pic.qscale_table[mbm_xy]) + 1) >> 1;
chroma_qp_avg[1] = (sl->chroma_qp[1] + get_chroma_qp(h, 1, h->cur_pic.qscale_table[mbm_xy]) + 1) >> 1;
if( dir == 0 ) {
filter_mb_edgev( &img_y[0], linesize, bS, qp, a, b, h, 1 );
if (chroma) {
@ -780,15 +779,15 @@ void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl,
mbn0_qp = h->cur_pic.qscale_table[sl->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[sl->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = (get_chroma_qp(h->ps.pps, 0, mb_qp) +
get_chroma_qp(h->ps.pps, 0, mbn0_qp) + 1) >> 1;
rqp[0] = (get_chroma_qp(h->ps.pps, 1, mb_qp) +
get_chroma_qp(h->ps.pps, 1, mbn0_qp) + 1) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
bqp[1] = (get_chroma_qp(h->ps.pps, 0, mb_qp) +
get_chroma_qp(h->ps.pps, 0, mbn1_qp) + 1 ) >> 1;
rqp[1] = (get_chroma_qp(h->ps.pps, 1, mb_qp) +
get_chroma_qp(h->ps.pps, 1, mbn1_qp) + 1 ) >> 1;
bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
/* Filter edge */
ff_tlog(h->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);

View File

@ -31,8 +31,7 @@
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "h264dec.h"
#include "h264_ps.h"
#include "h264.h"
#include "qpeldsp.h"
#include "thread.h"

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "h264dec.h"
#include "h264.h"
#undef MCFUNC

View File

@ -30,7 +30,7 @@
#include "internal.h"
#include "avcodec.h"
#include "h264dec.h"
#include "h264.h"
#include "mpegutils.h"
#include "libavutil/avassert.h"

View File

@ -20,15 +20,13 @@
#include "get_bits.h"
#include "golomb.h"
#include "h264.h"
#include "h264dec.h"
#include "h264_parse.h"
#include "h264_ps.h"
int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
const int *ref_count, int slice_type_nos,
H264PredWeightTable *pwt, void *logctx)
{
int list, i, j;
int list, i;
int luma_def, chroma_def;
pwt->use_weight = 0;
@ -90,14 +88,6 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
}
}
}
// for MBAFF
pwt->luma_weight[16 + 2 * i][list][0] = pwt->luma_weight[16 + 2 * i + 1][list][0] = pwt->luma_weight[i][list][0];
pwt->luma_weight[16 + 2 * i][list][1] = pwt->luma_weight[16 + 2 * i + 1][list][1] = pwt->luma_weight[i][list][1];
for (j = 0; j < 2; j++) {
pwt->chroma_weight[16 + 2 * i][list][j][0] = pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = pwt->chroma_weight[i][list][j][0];
pwt->chroma_weight[16 + 2 * i][list][j][1] = pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = pwt->chroma_weight[i][list][j][1];
}
}
if (slice_type_nos != AV_PICTURE_TYPE_B)
break;
@ -346,12 +336,12 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
for (i = 0; i < pkt.nb_nals; i++) {
H2645NAL *nal = &pkt.nals[i];
switch (nal->type) {
case H264_NAL_SPS:
case NAL_SPS:
ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0);
if (ret < 0)
goto fail;
break;
case H264_NAL_PPS:
case NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
nal->size_bits);
if (ret < 0)

View File

@ -25,7 +25,6 @@
#define AVCODEC_H264_PARSE_H
#include "get_bits.h"
#include "h264_ps.h"
typedef struct H264PredWeightTable {
int use_weight;
@ -53,7 +52,11 @@ typedef struct H264POCContext {
int prev_frame_num; ///< frame_num of the last pic for POC type 1/2
} H264POCContext;
int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
struct SPS;
struct PPS;
struct H264ParamSets;
int ff_h264_pred_weight_table(GetBitContext *gb, const struct SPS *sps,
const int *ref_count, int slice_type_nos,
H264PredWeightTable *pwt, void *logctx);
@ -73,20 +76,20 @@ int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available,
int mode, int is_chroma);
int ff_h264_parse_ref_count(int *plist_count, int ref_count[2],
GetBitContext *gb, const PPS *pps,
GetBitContext *gb, const struct PPS *pps,
int slice_type_nos, int picture_structure, void *logctx);
int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
const SPS *sps, H264POCContext *poc,
const struct SPS *sps, H264POCContext *poc,
int picture_structure, int nal_ref_idc);
int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps,
int ff_h264_decode_extradata(const uint8_t *data, int size, struct H264ParamSets *ps,
int *is_avc, int *nal_length_size,
int err_recognition, void *logctx);
/**
* compute profile from sps
*/
int ff_h264_get_profile(const SPS *sps);
int ff_h264_get_profile(const struct SPS *sps);
#endif /* AVCODEC_H264_PARSE_H */

View File

@ -36,12 +36,10 @@
#include "libavutil/mem.h"
#include "libavutil/pixfmt.h"
#include "avcodec.h"
#include "get_bits.h"
#include "golomb.h"
#include "h264.h"
#include "h264_sei.h"
#include "h264_ps.h"
#include "h264data.h"
#include "internal.h"
#include "mpegutils.h"
@ -106,14 +104,14 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf,
state >>= 1; // 2->1, 1->0, 0->0
} else if (state <= 5) {
int nalu_type = buf[i] & 0x1F;
if (nalu_type == H264_NAL_SEI || nalu_type == H264_NAL_SPS ||
nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD) {
if (nalu_type == NAL_SEI || nalu_type == NAL_SPS ||
nalu_type == NAL_PPS || nalu_type == NAL_AUD) {
if (pc->frame_start_found) {
i++;
goto found;
}
} else if (nalu_type == H264_NAL_SLICE || nalu_type == H264_NAL_DPA ||
nalu_type == H264_NAL_IDR_SLICE) {
} else if (nalu_type == NAL_SLICE || nalu_type == NAL_DPA ||
nalu_type == NAL_IDR_SLICE) {
state += 8;
continue;
}
@ -303,10 +301,10 @@ static inline int parse_nal_units(AVCodecParserContext *s,
state = buf[buf_index];
switch (state & 0x1f) {
case H264_NAL_SLICE:
case H264_NAL_IDR_SLICE:
case NAL_SLICE:
case NAL_IDR_SLICE:
// Do not walk the whole buffer just to decode slice header
if ((state & 0x1f) == H264_NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
/* IDR or disposable slice
* No need to decode many bytes because MMCOs shall not be present. */
if (src_length > 60)
@ -332,17 +330,17 @@ static inline int parse_nal_units(AVCodecParserContext *s,
nal.type = get_bits(&nal.gb, 5);
switch (nal.type) {
case H264_NAL_SPS:
case NAL_SPS:
ff_h264_decode_seq_parameter_set(&nal.gb, avctx, &p->ps, 0);
break;
case H264_NAL_PPS:
case NAL_PPS:
ff_h264_decode_picture_parameter_set(&nal.gb, avctx, &p->ps,
nal.size_bits);
break;
case H264_NAL_SEI:
case NAL_SEI:
ff_h264_sei_decode(&p->sei, &nal.gb, &p->ps, avctx);
break;
case H264_NAL_IDR_SLICE:
case NAL_IDR_SLICE:
s->key_frame = 1;
p->poc.prev_frame_num = 0;
@ -350,7 +348,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
p->poc.prev_poc_msb =
p->poc.prev_poc_lsb = 0;
/* fall through */
case H264_NAL_SLICE:
case NAL_SLICE:
get_ue_golomb_long(&nal.gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&nal.gb);
s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5];
@ -369,26 +367,13 @@ static inline int parse_nal_units(AVCodecParserContext *s,
"non-existing PPS %u referenced\n", pps_id);
goto fail;
}
av_buffer_unref(&p->ps.pps_ref);
av_buffer_unref(&p->ps.sps_ref);
p->ps.pps = NULL;
p->ps.sps = NULL;
p->ps.pps_ref = av_buffer_ref(p->ps.pps_list[pps_id]);
if (!p->ps.pps_ref)
goto fail;
p->ps.pps = (const PPS*)p->ps.pps_ref->data;
p->ps.pps = (const PPS*)p->ps.pps_list[pps_id]->data;
if (!p->ps.sps_list[p->ps.pps->sps_id]) {
av_log(avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n", p->ps.pps->sps_id);
goto fail;
}
p->ps.sps_ref = av_buffer_ref(p->ps.sps_list[p->ps.pps->sps_id]);
if (!p->ps.sps_ref)
goto fail;
p->ps.sps = (const SPS*)p->ps.sps_ref->data;
p->ps.sps = (SPS*)p->ps.sps_list[p->ps.pps->sps_id]->data;
sps = p->ps.sps;
@ -440,7 +425,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
}
}
if (nal.type == H264_NAL_IDR_SLICE)
if (nal.type == NAL_IDR_SLICE)
get_ue_golomb_long(&nal.gb); /* idr_pic_id */
if (sps->poc_type == 0) {
p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb);
@ -469,7 +454,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
* FIXME: MMCO_RESET could appear in non-first slice.
* Maybe, we should parse all undisposable non-IDR slice of this
* picture until encountering MMCO_RESET in a slice of it. */
if (nal.ref_idc && nal.type != H264_NAL_IDR_SLICE) {
if (nal.ref_idc && nal.type != NAL_IDR_SLICE) {
got_reset = scan_mmco_reset(s, &nal.gb, avctx);
if (got_reset < 0)
goto fail;
@ -637,17 +622,17 @@ static int h264_split(AVCodecContext *avctx,
if ((state & 0xFFFFFF00) != 0x100)
break;
nalu_type = state & 0x1F;
if (nalu_type == H264_NAL_SPS) {
if (nalu_type == NAL_SPS) {
has_sps = 1;
} else if (nalu_type == H264_NAL_PPS)
} else if (nalu_type == NAL_PPS)
has_pps = 1;
/* else if (nalu_type == 0x01 ||
* nalu_type == 0x02 ||
* nalu_type == 0x05) {
* }
*/
else if ((nalu_type != H264_NAL_SEI || has_pps) &&
nalu_type != H264_NAL_AUD && nalu_type != H264_NAL_SPS_EXT &&
else if ((nalu_type != NAL_SEI || has_pps) &&
nalu_type != NAL_AUD && nalu_type != NAL_SPS_EXT &&
nalu_type != 0x0f) {
if (has_sps) {
while (ptr - 4 > buf && ptr[-5] == 0)

View File

@ -33,10 +33,11 @@
#include "cabac_functions.h"
#include "error_resilience.h"
#include "avcodec.h"
#include "h264dec.h"
#include "h264.h"
#include "h264data.h"
#include "h264chroma.h"
#include "h264_mvpred.h"
#include "golomb.h"
#include "mathops.h"
#include "mpegutils.h"
#include "rectangle.h"
@ -164,7 +165,7 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
if (!h->droppable) {
err = ff_h264_execute_ref_pic_marking(h);
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->poc.prev_poc_msb = h->poc.poc_msb;
h->poc.prev_poc_lsb = h->poc.poc_lsb;
}

View File

@ -31,15 +31,13 @@
#include "internal.h"
#include "mathops.h"
#include "avcodec.h"
#include "h264.h"
#include "h264data.h"
#include "h264_ps.h"
#include "golomb.h"
#define MAX_LOG2_MAX_FRAME_NUM (12 + 4)
#define MIN_LOG2_MAX_FRAME_NUM 4
#define EXTENDED_SAR 255
static const uint8_t default_scaling4[2][16] = {
{ 6, 13, 20, 28, 13, 20, 28, 32,
20, 28, 32, 37, 28, 32, 37, 42 },
@ -267,9 +265,8 @@ static void decode_scaling_list(GetBitContext *gb, uint8_t *factors, int size,
}
}
/* returns non zero if the provided SPS scaling matrix has been filled */
static int decode_scaling_matrices(GetBitContext *gb, const SPS *sps,
const PPS *pps, int is_sps,
static void decode_scaling_matrices(GetBitContext *gb, SPS *sps,
PPS *pps, int is_sps,
uint8_t(*scaling_matrix4)[16],
uint8_t(*scaling_matrix8)[64])
{
@ -280,9 +277,8 @@ static int decode_scaling_matrices(GetBitContext *gb, const SPS *sps,
fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0],
fallback_sps ? sps->scaling_matrix8[3] : default_scaling8[1]
};
int ret = 0;
if (get_bits1(gb)) {
ret = is_sps;
sps->scaling_matrix_present |= is_sps;
decode_scaling_list(gb, scaling_matrix4[0], 16, default_scaling4[0], fallback[0]); // Intra, Y
decode_scaling_list(gb, scaling_matrix4[1], 16, default_scaling4[0], scaling_matrix4[0]); // Intra, Cr
decode_scaling_list(gb, scaling_matrix4[2], 16, default_scaling4[0], scaling_matrix4[1]); // Intra, Cb
@ -300,8 +296,6 @@ static int decode_scaling_matrices(GetBitContext *gb, const SPS *sps,
}
}
}
return ret;
}
void ff_h264_ps_uninit(H264ParamSets *ps)
@ -407,7 +401,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
goto fail;
}
sps->transform_bypass = get_bits1(gb);
sps->scaling_matrix_present |= decode_scaling_matrices(gb, sps, NULL, 1,
decode_scaling_matrices(gb, sps, NULL, 1,
sps->scaling_matrix4, sps->scaling_matrix8);
} else {
sps->chroma_format_idc = 1;
@ -457,7 +451,8 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
sps->ref_frame_count = get_ue_golomb_31(gb);
if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
if (sps->ref_frame_count > MAX_DELAYED_PIC_COUNT) {
if (sps->ref_frame_count > H264_MAX_PICTURE_COUNT - 2 ||
sps->ref_frame_count > 16U) {
av_log(avctx, AV_LOG_ERROR,
"too many reference frames %d\n", sps->ref_frame_count);
goto fail;
@ -465,6 +460,13 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
sps->gaps_in_frame_num_allowed_flag = get_bits1(gb);
sps->mb_width = get_ue_golomb(gb) + 1;
sps->mb_height = get_ue_golomb(gb) + 1;
if ((unsigned)sps->mb_width >= INT_MAX / 16 ||
(unsigned)sps->mb_height >= INT_MAX / 16 ||
av_image_check_size(16 * sps->mb_width,
16 * sps->mb_height, 0, avctx)) {
av_log(avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
goto fail;
}
sps->frame_mbs_only_flag = get_bits1(gb);
if (!sps->frame_mbs_only_flag)
@ -472,14 +474,6 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
else
sps->mb_aff = 0;
if ((unsigned)sps->mb_width >= INT_MAX / 16 ||
(unsigned)sps->mb_height >= INT_MAX / (16 * (2 - sps->frame_mbs_only_flag)) ||
av_image_check_size(16 * sps->mb_width,
16 * sps->mb_height * (2 - sps->frame_mbs_only_flag), 0, avctx)) {
av_log(avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
goto fail;
}
sps->direct_8x8_inference_flag = get_bits1(gb);
#ifndef ALLOW_INTERLACE
@ -561,8 +555,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
/* if the maximum delay is not stored in the SPS, derive it based on the
* level */
if (!sps->bitstream_restriction_flag &&
(sps->ref_frame_count || avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT)) {
if (!sps->bitstream_restriction_flag) {
sps->num_reorder_frames = MAX_DELAYED_PIC_COUNT - 1;
for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) {
if (level_max_dpb_mbs[i][0] == sps->level_idc) {
@ -714,7 +707,7 @@ int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avct
H264ParamSets *ps, int bit_length)
{
AVBufferRef *pps_buf;
const SPS *sps;
SPS *sps;
unsigned int pps_id = get_ue_golomb(gb);
PPS *pps;
int qp_bd_offset;
@ -733,9 +726,7 @@ int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avct
pps->data_size = gb->buffer_end - gb->buffer;
if (pps->data_size > sizeof(pps->data)) {
av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized PPS "
"(%"SIZE_SPECIFIER" > %"SIZE_SPECIFIER")\n",
pps->data_size, sizeof(pps->data));
av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized PPS\n");
pps->data_size = sizeof(pps->data);
}
memcpy(pps->data, gb->buffer, pps->data_size);
@ -747,7 +738,7 @@ int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avct
ret = AVERROR_INVALIDDATA;
goto fail;
}
sps = (const SPS*)ps->sps_list[pps->sps_id]->data;
sps = (SPS*)ps->sps_list[pps->sps_id]->data;
if (sps->bit_depth_luma > 14) {
av_log(avctx, AV_LOG_ERROR,
"Invalid luma bit depth=%d\n",

View File

@ -1,164 +0,0 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* H.264 parameter set handling
*/
#ifndef AVCODEC_H264_PS_H
#define AVCODEC_H264_PS_H
#include <stdint.h>
#include "libavutil/buffer.h"
#include "libavutil/pixfmt.h"
#include "libavutil/rational.h"
#include "avcodec.h"
#include "get_bits.h"
#include "h264.h"
#define MAX_SPS_COUNT 32
#define MAX_PPS_COUNT 256
/**
* Sequence parameter set
*/
typedef struct SPS {
unsigned int sps_id;
int profile_idc;
int level_idc;
int chroma_format_idc;
int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag
int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4
int poc_type; ///< pic_order_cnt_type
int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4
int delta_pic_order_always_zero_flag;
int offset_for_non_ref_pic;
int offset_for_top_to_bottom_field;
int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle
int ref_frame_count; ///< num_ref_frames
int gaps_in_frame_num_allowed_flag;
int mb_width; ///< pic_width_in_mbs_minus1 + 1
int mb_height; ///< pic_height_in_map_units_minus1 + 1
int frame_mbs_only_flag;
int mb_aff; ///< mb_adaptive_frame_field_flag
int direct_8x8_inference_flag;
int crop; ///< frame_cropping_flag
/* those 4 are already in luma samples */
unsigned int crop_left; ///< frame_cropping_rect_left_offset
unsigned int crop_right; ///< frame_cropping_rect_right_offset
unsigned int crop_top; ///< frame_cropping_rect_top_offset
unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset
int vui_parameters_present_flag;
AVRational sar;
int video_signal_type_present_flag;
int full_range;
int colour_description_present_flag;
enum AVColorPrimaries color_primaries;
enum AVColorTransferCharacteristic color_trc;
enum AVColorSpace colorspace;
int timing_info_present_flag;
uint32_t num_units_in_tick;
uint32_t time_scale;
int fixed_frame_rate_flag;
short offset_for_ref_frame[256]; // FIXME dyn aloc?
int bitstream_restriction_flag;
int num_reorder_frames;
int scaling_matrix_present;
uint8_t scaling_matrix4[6][16];
uint8_t scaling_matrix8[6][64];
int nal_hrd_parameters_present_flag;
int vcl_hrd_parameters_present_flag;
int pic_struct_present_flag;
int time_offset_length;
int cpb_cnt; ///< See H.264 E.1.2
int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1
int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1
int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1
int bit_depth_luma; ///< bit_depth_luma_minus8 + 8
int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
int residual_color_transform_flag; ///< residual_colour_transform_flag
int constraint_set_flags; ///< constraint_set[0-3]_flag
uint8_t data[4096];
size_t data_size;
} SPS;
/**
* Picture parameter set
*/
typedef struct PPS {
unsigned int sps_id;
int cabac; ///< entropy_coding_mode_flag
int pic_order_present; ///< pic_order_present_flag
int slice_group_count; ///< num_slice_groups_minus1 + 1
int mb_slice_group_map_type;
unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
int weighted_pred; ///< weighted_pred_flag
int weighted_bipred_idc;
int init_qp; ///< pic_init_qp_minus26 + 26
int init_qs; ///< pic_init_qs_minus26 + 26
int chroma_qp_index_offset[2];
int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
int constrained_intra_pred; ///< constrained_intra_pred_flag
int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag
int transform_8x8_mode; ///< transform_8x8_mode_flag
uint8_t scaling_matrix4[6][16];
uint8_t scaling_matrix8[6][64];
uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
int chroma_qp_diff;
uint8_t data[4096];
size_t data_size;
uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16];
uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
uint32_t(*dequant4_coeff[6])[16];
uint32_t(*dequant8_coeff[6])[64];
} PPS;
typedef struct H264ParamSets {
AVBufferRef *sps_list[MAX_SPS_COUNT];
AVBufferRef *pps_list[MAX_PPS_COUNT];
AVBufferRef *pps_ref;
AVBufferRef *sps_ref;
/* currently active parameters sets */
const PPS *pps;
const SPS *sps;
} H264ParamSets;
/**
* Decode SPS
*/
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
H264ParamSets *ps, int ignore_truncation);
/**
* Decode PPS
*/
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
H264ParamSets *ps, int bit_length);
/**
* Uninit H264 param sets structure.
*/
void ff_h264_ps_uninit(H264ParamSets *ps);
#endif /* AVCODEC_H264_PS_H */

View File

@ -31,7 +31,6 @@
#include "internal.h"
#include "avcodec.h"
#include "h264.h"
#include "h264dec.h"
#include "golomb.h"
#include "mpegutils.h"
@ -271,32 +270,7 @@ static int pic_num_extract(const H264Context *h, int pic_num, int *structure)
return pic_num;
}
static void h264_fill_mbaff_ref_list(H264SliceContext *sl)
{
int list, i, j;
for (list = 0; list < sl->list_count; list++) {
for (i = 0; i < sl->ref_count[list]; i++) {
H264Ref *frame = &sl->ref_list[list][i];
H264Ref *field = &sl->ref_list[list][16 + 2 * i];
field[0] = *frame;
for (j = 0; j < 3; j++)
field[0].linesize[j] <<= 1;
field[0].reference = PICT_TOP_FIELD;
field[0].poc = field[0].parent->field_poc[0];
field[1] = field[0];
for (j = 0; j < 3; j++)
field[1].data[j] += frame->parent->f->linesize[j];
field[1].reference = PICT_BOTTOM_FIELD;
field[1].poc = field[1].parent->field_poc[1];
}
}
}
int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
{
int list, index, pic_structure;
@ -306,90 +280,102 @@ int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
h264_initialise_ref_list(h, sl);
for (list = 0; list < sl->list_count; list++) {
int pred = sl->curr_pic_num;
if (get_bits1(&sl->gb)) { // ref_pic_list_modification_flag_l[01]
int pred = h->curr_pic_num;
for (index = 0; index < sl->nb_ref_modifications[list]; index++) {
unsigned int modification_of_pic_nums_idc = sl->ref_modifications[list][index].op;
unsigned int val = sl->ref_modifications[list][index].val;
unsigned int pic_id;
int i;
H264Picture *ref = NULL;
for (index = 0; ; index++) {
unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&sl->gb);
unsigned int pic_id;
int i;
H264Picture *ref = NULL;
switch (modification_of_pic_nums_idc) {
case 0:
case 1: {
const unsigned int abs_diff_pic_num = val + 1;
int frame_num;
if (modification_of_pic_nums_idc == 3)
break;
if (abs_diff_pic_num > sl->max_pic_num) {
if (index >= sl->ref_count[list]) {
av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1;
}
switch (modification_of_pic_nums_idc) {
case 0:
case 1: {
const unsigned int abs_diff_pic_num = get_ue_golomb_long(&sl->gb) + 1;
int frame_num;
if (abs_diff_pic_num > h->max_pic_num) {
av_log(h->avctx, AV_LOG_ERROR,
"abs_diff_pic_num overflow\n");
return AVERROR_INVALIDDATA;
}
if (modification_of_pic_nums_idc == 0)
pred -= abs_diff_pic_num;
else
pred += abs_diff_pic_num;
pred &= h->max_pic_num - 1;
frame_num = pic_num_extract(h, pred, &pic_structure);
for (i = h->short_ref_count - 1; i >= 0; i--) {
ref = h->short_ref[i];
assert(ref->reference);
assert(!ref->long_ref);
if (ref->frame_num == frame_num &&
(ref->reference & pic_structure))
break;
}
if (i >= 0)
ref->pic_id = pred;
break;
}
case 2: {
int long_idx;
pic_id = get_ue_golomb(&sl->gb); // long_term_pic_idx
long_idx = pic_num_extract(h, pic_id, &pic_structure);
if (long_idx > 31U) {
av_log(h->avctx, AV_LOG_ERROR,
"long_term_pic_idx overflow\n");
return AVERROR_INVALIDDATA;
}
ref = h->long_ref[long_idx];
assert(!(ref && !ref->reference));
if (ref && (ref->reference & pic_structure) && !mismatches_ref(h, ref)) {
ref->pic_id = pic_id;
assert(ref->long_ref);
i = 0;
} else {
i = -1;
}
break;
}
default:
av_log(h->avctx, AV_LOG_ERROR,
"abs_diff_pic_num overflow\n");
"illegal modification_of_pic_nums_idc %u\n",
modification_of_pic_nums_idc);
return AVERROR_INVALIDDATA;
}
if (modification_of_pic_nums_idc == 0)
pred -= abs_diff_pic_num;
else
pred += abs_diff_pic_num;
pred &= sl->max_pic_num - 1;
frame_num = pic_num_extract(h, pred, &pic_structure);
for (i = h->short_ref_count - 1; i >= 0; i--) {
ref = h->short_ref[i];
assert(ref->reference);
assert(!ref->long_ref);
if (ref->frame_num == frame_num &&
(ref->reference & pic_structure))
break;
}
if (i >= 0)
ref->pic_id = pred;
break;
}
case 2: {
int long_idx;
pic_id = val; // long_term_pic_idx
long_idx = pic_num_extract(h, pic_id, &pic_structure);
if (long_idx > 31U) {
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"long_term_pic_idx overflow\n");
return AVERROR_INVALIDDATA;
}
ref = h->long_ref[long_idx];
assert(!(ref && !ref->reference));
if (ref && (ref->reference & pic_structure)) {
ref->pic_id = pic_id;
assert(ref->long_ref);
i = 0;
"reference picture missing during reorder\n");
memset(&sl->ref_list[list][index], 0, sizeof(sl->ref_list[0][0])); // FIXME
} else {
i = -1;
}
break;
}
default:
av_assert1(0);
}
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"reference picture missing during reorder\n");
memset(&sl->ref_list[list][index], 0, sizeof(sl->ref_list[0][0])); // FIXME
} else {
for (i = index; i + 1 < sl->ref_count[list]; i++) {
if (sl->ref_list[list][i].parent &&
ref->long_ref == sl->ref_list[list][i].parent->long_ref &&
ref->pic_id == sl->ref_list[list][i].pic_id)
break;
}
for (; i > index; i--) {
sl->ref_list[list][i] = sl->ref_list[list][i - 1];
}
ref_from_h264pic(&sl->ref_list[list][index], ref);
if (FIELD_PICTURE(h)) {
pic_as_field(&sl->ref_list[list][index], pic_structure);
for (i = index; i + 1 < sl->ref_count[list]; i++) {
if (sl->ref_list[list][i].parent &&
ref->long_ref == sl->ref_list[list][i].parent->long_ref &&
ref->pic_id == sl->ref_list[list][i].pic_id)
break;
}
for (; i > index; i--) {
sl->ref_list[list][i] = sl->ref_list[list][i - 1];
}
ref_from_h264pic(&sl->ref_list[list][index], ref);
if (FIELD_PICTURE(h)) {
pic_as_field(&sl->ref_list[list][index], pic_structure);
}
}
}
}
@ -412,45 +398,39 @@ int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
}
}
if (FRAME_MBAFF(h))
h264_fill_mbaff_ref_list(sl);
return 0;
}
int ff_h264_decode_ref_pic_list_reordering(H264SliceContext *sl, void *logctx)
void ff_h264_fill_mbaff_ref_list(H264SliceContext *sl)
{
int list, index;
sl->nb_ref_modifications[0] = 0;
sl->nb_ref_modifications[1] = 0;
int list, i, j;
for (list = 0; list < sl->list_count; list++) {
if (!get_bits1(&sl->gb)) // ref_pic_list_modification_flag_l[01]
continue;
for (i = 0; i < sl->ref_count[list]; i++) {
H264Ref *frame = &sl->ref_list[list][i];
H264Ref *field = &sl->ref_list[list][16 + 2 * i];
for (index = 0; ; index++) {
unsigned int op = get_ue_golomb_31(&sl->gb);
field[0] = *frame;
if (op == 3)
break;
for (j = 0; j < 3; j++)
field[0].linesize[j] <<= 1;
field[0].reference = PICT_TOP_FIELD;
field[0].poc = field[0].parent->field_poc[0];
if (index >= sl->ref_count[list]) {
av_log(logctx, AV_LOG_ERROR, "reference count overflow\n");
return AVERROR_INVALIDDATA;
} else if (op > 2) {
av_log(logctx, AV_LOG_ERROR,
"illegal modification_of_pic_nums_idc %u\n",
op);
return AVERROR_INVALIDDATA;
field[1] = field[0];
for (j = 0; j < 3; j++)
field[1].data[j] += frame->parent->f->linesize[j];
field[1].reference = PICT_BOTTOM_FIELD;
field[1].poc = field[1].parent->field_poc[1];
sl->pwt.luma_weight[16 + 2 * i][list][0] = sl->pwt.luma_weight[16 + 2 * i + 1][list][0] = sl->pwt.luma_weight[i][list][0];
sl->pwt.luma_weight[16 + 2 * i][list][1] = sl->pwt.luma_weight[16 + 2 * i + 1][list][1] = sl->pwt.luma_weight[i][list][1];
for (j = 0; j < 2; j++) {
sl->pwt.chroma_weight[16 + 2 * i][list][j][0] = sl->pwt.chroma_weight[16 + 2 * i + 1][list][j][0] = sl->pwt.chroma_weight[i][list][j][0];
sl->pwt.chroma_weight[16 + 2 * i][list][j][1] = sl->pwt.chroma_weight[16 + 2 * i + 1][list][j][1] = sl->pwt.chroma_weight[i][list][j][1];
}
sl->ref_modifications[list][index].val = get_ue_golomb_long(&sl->gb);
sl->ref_modifications[list][index].op = op;
sl->nb_ref_modifications[list]++;
}
}
return 0;
}
/**
@ -582,43 +562,67 @@ void ff_h264_remove_all_refs(H264Context *h)
h->short_ref_count = 0;
memset(h->default_ref, 0, sizeof(h->default_ref));
for (i = 0; i < h->nb_slice_ctx; i++) {
H264SliceContext *sl = &h->slice_ctx[i];
sl->list_count = sl->ref_count[0] = sl->ref_count[1] = 0;
memset(sl->ref_list, 0, sizeof(sl->ref_list));
}
}
static void generate_sliding_window_mmcos(H264Context *h)
static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos)
{
MMCO *mmco = h->mmco;
int nb_mmco = 0;
int i;
for (i = 0; i < n_mmcos; i++) {
if (mmco1[i].opcode != mmco2[i].opcode) {
av_log(NULL, AV_LOG_ERROR, "MMCO opcode [%d, %d] at %d mismatches between slices\n",
mmco1[i].opcode, mmco2[i].opcode, i);
return -1;
}
}
return 0;
}
int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
int mmco_index = 0, i = 0;
if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count >= h->ps.sps->ref_frame_count &&
!(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
nb_mmco = 1;
mmco_index = 1;
if (FIELD_PICTURE(h)) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
nb_mmco = 2;
mmco_index = 2;
}
}
h->nb_mmco = nb_mmco;
if (first_slice) {
h->mmco_index = mmco_index;
} else if (!first_slice && mmco_index >= 0 &&
(mmco_index != h->mmco_index ||
(i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
av_log(h->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d]\n",
mmco_index, h->mmco_index);
return AVERROR_INVALIDDATA;
}
return 0;
}
int ff_h264_execute_ref_pic_marking(H264Context *h)
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
{
MMCO *mmco = h->mmco;
int mmco_count;
int i, av_uninit(j);
int pps_ref_count[2] = {0};
int current_ref_assigned = 0, err = 0;
H264Picture *av_uninit(pic);
if (!h->explicit_ref_marking)
generate_sliding_window_mmcos(h);
mmco_count = h->nb_mmco;
if ((h->avctx->debug & FF_DEBUG_MMCO) && mmco_count == 0)
av_log(h->avctx, AV_LOG_DEBUG, "no mmco here\n");
@ -821,32 +825,30 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
return (h->avctx->err_recognition & AV_EF_EXPLODE) ? err : 0;
}
int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
const H2645NAL *nal, void *logctx)
int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
int first_slice)
{
int i;
MMCO *mmco = sl->mmco;
int nb_mmco = 0;
int i, ret;
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = mmco_temp;
int mmco_index = 0;
if (nal->type == H264_NAL_IDR_SLICE) { // FIXME fields
if (h->nal_unit_type == NAL_IDR_SLICE) { // FIXME fields
skip_bits1(gb); // broken_link
if (get_bits1(gb)) {
mmco[0].opcode = MMCO_LONG;
mmco[0].long_arg = 0;
nb_mmco = 1;
mmco_index = 1;
}
sl->explicit_ref_marking = 1;
} else {
sl->explicit_ref_marking = get_bits1(gb);
if (sl->explicit_ref_marking) {
if (get_bits1(gb)) { // adaptive_ref_pic_marking_mode_flag
for (i = 0; i < MAX_MMCO_COUNT; i++) {
MMCOOpcode opcode = get_ue_golomb_31(gb);
mmco[i].opcode = opcode;
if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) {
mmco[i].short_pic_num =
(sl->curr_pic_num - get_ue_golomb_long(gb) - 1) &
(sl->max_pic_num - 1);
(h->curr_pic_num - get_ue_golomb_long(gb) - 1) &
(h->max_pic_num - 1);
#if 0
if (mmco[i].short_pic_num >= h->short_ref_count ||
!h->short_ref[mmco[i].short_pic_num]) {
@ -863,8 +865,8 @@ int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
if (long_arg >= 32 ||
(long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&
long_arg == 16) &&
!(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(sl)))) {
av_log(logctx, AV_LOG_ERROR,
!(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(h)))) {
av_log(h->avctx, AV_LOG_ERROR,
"illegal long ref in memory management control "
"operation %d\n", opcode);
return -1;
@ -873,7 +875,7 @@ int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
}
if (opcode > (unsigned) MMCO_LONG) {
av_log(logctx, AV_LOG_ERROR,
av_log(h->avctx, AV_LOG_ERROR,
"illegal memory management control operation %d\n",
opcode);
return -1;
@ -881,11 +883,28 @@ int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
if (opcode == MMCO_END)
break;
}
nb_mmco = i;
mmco_index = i;
} else {
if (first_slice) {
ret = ff_generate_sliding_window_mmcos(h, first_slice);
if (ret < 0 && h->avctx->err_recognition & AV_EF_EXPLODE)
return ret;
}
mmco_index = -1;
}
}
sl->nb_mmco = nb_mmco;
if (first_slice && mmco_index != -1) {
memcpy(h->mmco, mmco_temp, sizeof(h->mmco));
h->mmco_index = mmco_index;
} else if (!first_slice && mmco_index >= 0 &&
(mmco_index != h->mmco_index ||
check_opcodes(h->mmco, mmco_temp, mmco_index))) {
av_log(h->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d]\n",
mmco_index, h->mmco_index);
return AVERROR_INVALIDDATA;
}
return 0;
}

View File

@ -28,7 +28,7 @@
#include "avcodec.h"
#include "get_bits.h"
#include "golomb.h"
#include "h264_ps.h"
#include "h264.h"
#include "h264_sei.h"
#include "internal.h"
@ -278,7 +278,7 @@ static int decode_buffering_period(H264SEIBufferingPeriod *h, GetBitContext *gb,
{
unsigned int sps_id;
int sched_sel_idx;
const SPS *sps;
SPS *sps;
sps_id = get_ue_golomb_31(gb);
if (sps_id > 31 || !ps->sps_list[sps_id]) {
@ -286,7 +286,7 @@ static int decode_buffering_period(H264SEIBufferingPeriod *h, GetBitContext *gb,
"non-existing SPS %d referenced in buffering period\n", sps_id);
return sps_id > 31 ? AVERROR_INVALIDDATA : AVERROR_PS_NOT_FOUND;
}
sps = (const SPS*)ps->sps_list[sps_id]->data;
sps = (SPS*)ps->sps_list[sps_id]->data;
// NOTE: This is really so duplicated in the standard... See H.264, D.1.1
if (sps->nal_hrd_parameters_present_flag) {

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
#include "libavutil/avutil.h"
#include "avcodec.h"
#include "h264dec.h"
#include "h264.h"
#include "h264data.h"
const uint8_t ff_h264_golomb_to_pict_type[5] = {

View File

@ -21,7 +21,7 @@
#include <stdint.h>
#include "h264dec.h"
#include "h264.h"
extern const uint8_t ff_h264_golomb_to_pict_type[5];
extern const uint8_t ff_h264_golomb_to_intra4x4_cbp[48];

View File

@ -1,864 +0,0 @@
/*
* H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* H.264 / AVC / MPEG-4 part10 codec.
* @author Michael Niedermayer <michaelni@gmx.at>
*/
#ifndef AVCODEC_H264DEC_H
#define AVCODEC_H264DEC_H
#include "libavutil/buffer.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/thread.h"
#include "cabac.h"
#include "error_resilience.h"
#include "h264_parse.h"
#include "h264_ps.h"
#include "h264_sei.h"
#include "h2645_parse.h"
#include "h264chroma.h"
#include "h264dsp.h"
#include "h264pred.h"
#include "h264qpel.h"
#include "internal.h"
#include "mpegutils.h"
#include "parser.h"
#include "qpeldsp.h"
#include "rectangle.h"
#include "videodsp.h"
#define H264_MAX_PICTURE_COUNT 36
#define MAX_MMCO_COUNT 66
#define MAX_DELAYED_PIC_COUNT 16
#define MAX_MBPAIR_SIZE (256*1024) // a tighter bound could be calculated if someone cares about a few bytes
/* Compiling in interlaced support reduces the speed
* of progressive decoding by about 2%. */
#define ALLOW_INTERLACE
#define FMO 0
/**
* The maximum number of slices supported by the decoder.
* must be a power of 2
*/
#define MAX_SLICES 32
#ifdef ALLOW_INTERLACE
#define MB_MBAFF(h) (h)->mb_mbaff
#define MB_FIELD(sl) (sl)->mb_field_decoding_flag
#define FRAME_MBAFF(h) (h)->mb_aff_frame
#define FIELD_PICTURE(h) ((h)->picture_structure != PICT_FRAME)
#define LEFT_MBS 2
#define LTOP 0
#define LBOT 1
#define LEFT(i) (i)
#else
#define MB_MBAFF(h) 0
#define MB_FIELD(sl) 0
#define FRAME_MBAFF(h) 0
#define FIELD_PICTURE(h) 0
#undef IS_INTERLACED
#define IS_INTERLACED(mb_type) 0
#define LEFT_MBS 1
#define LTOP 0
#define LBOT 0
#define LEFT(i) 0
#endif
#define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h))
#ifndef CABAC
#define CABAC(h) (h)->ps.pps->cabac
#endif
#define CHROMA(h) ((h)->ps.sps->chroma_format_idc)
#define CHROMA422(h) ((h)->ps.sps->chroma_format_idc == 2)
#define CHROMA444(h) ((h)->ps.sps->chroma_format_idc == 3)
#define MB_TYPE_REF0 MB_TYPE_ACPRED // dirty but it fits in 16 bit
#define MB_TYPE_8x8DCT 0x01000000
#define IS_REF0(a) ((a) & MB_TYPE_REF0)
#define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT)
/**
* Memory management control operation opcode.
*/
typedef enum MMCOOpcode {
MMCO_END = 0,
MMCO_SHORT2UNUSED,
MMCO_LONG2UNUSED,
MMCO_SHORT2LONG,
MMCO_SET_MAX_LONG,
MMCO_RESET,
MMCO_LONG,
} MMCOOpcode;
/**
* Memory management control operation.
*/
typedef struct MMCO {
MMCOOpcode opcode;
int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num)
int long_arg; ///< index, pic_num, or num long refs depending on opcode
} MMCO;
typedef struct H264Picture {
AVFrame *f;
ThreadFrame tf;
AVBufferRef *qscale_table_buf;
int8_t *qscale_table;
AVBufferRef *motion_val_buf[2];
int16_t (*motion_val[2])[2];
AVBufferRef *mb_type_buf;
uint32_t *mb_type;
AVBufferRef *hwaccel_priv_buf;
void *hwaccel_picture_private; ///< hardware accelerator private data
AVBufferRef *ref_index_buf[2];
int8_t *ref_index[2];
int field_poc[2]; ///< top/bottom POC
int poc; ///< frame POC
int frame_num; ///< frame_num (raw frame_num from slice header)
int mmco_reset; /**< MMCO_RESET set this 1. Reordering code must
not mix pictures before and after MMCO_RESET. */
int pic_id; /**< pic_num (short -> no wrap version of pic_num,
pic_num & max_pic_num; long -> long_pic_num) */
int long_ref; ///< 1->long term reference 0->short term reference
int ref_poc[2][2][32]; ///< POCs of the frames/fields used as reference (FIXME need per slice)
int ref_count[2][2]; ///< number of entries in ref_poc (FIXME need per slice)
int mbaff; ///< 1 -> MBAFF frame 0-> not MBAFF
int field_picture; ///< whether or not picture was encoded in separate fields
int reference;
int recovered; ///< picture at IDR or recovery point + recovery count
int invalid_gap;
int sei_recovery_frame_cnt;
int crop;
int crop_left;
int crop_top;
} H264Picture;
typedef struct H264Ref {
uint8_t *data[3];
int linesize[3];
int reference;
int poc;
int pic_id;
H264Picture *parent;
} H264Ref;
typedef struct H264SliceContext {
struct H264Context *h264;
GetBitContext gb;
ERContext er;
int slice_num;
int slice_type;
int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P)
int slice_type_fixed;
int qscale;
int chroma_qp[2]; // QPc
int qp_thresh; ///< QP threshold to skip loopfilter
int last_qscale_diff;
// deblock
int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0
int slice_alpha_c0_offset;
int slice_beta_offset;
H264PredWeightTable pwt;
int prev_mb_skipped;
int next_mb_skipped;
int chroma_pred_mode;
int intra16x16_pred_mode;
int8_t intra4x4_pred_mode_cache[5 * 8];
int8_t(*intra4x4_pred_mode);
int topleft_mb_xy;
int top_mb_xy;
int topright_mb_xy;
int left_mb_xy[LEFT_MBS];
int topleft_type;
int top_type;
int topright_type;
int left_type[LEFT_MBS];
const uint8_t *left_block;
int topleft_partition;
unsigned int topleft_samples_available;
unsigned int top_samples_available;
unsigned int topright_samples_available;
unsigned int left_samples_available;
ptrdiff_t linesize, uvlinesize;
ptrdiff_t mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff
ptrdiff_t mb_uvlinesize;
int mb_x, mb_y;
int mb_xy;
int resync_mb_x;
int resync_mb_y;
unsigned int first_mb_addr;
// index of the first MB of the next slice
int next_slice_idx;
int mb_skip_run;
int is_complex;
int picture_structure;
int mb_field_decoding_flag;
int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag
int redundant_pic_count;
/**
* number of neighbors (top and/or left) that used 8x8 dct
*/
int neighbor_transform_size;
int direct_spatial_mv_pred;
int col_parity;
int col_fieldoff;
int cbp;
int top_cbp;
int left_cbp;
int dist_scale_factor[32];
int dist_scale_factor_field[2][32];
int map_col_to_list0[2][16 + 32];
int map_col_to_list0_field[2][2][16 + 32];
/**
* num_ref_idx_l0/1_active_minus1 + 1
*/
unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
unsigned int list_count;
H264Ref ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
* Reordered version of default_ref_list
* according to picture reordering in slice header */
struct {
uint8_t op;
uint32_t val;
} ref_modifications[2][32];
int nb_ref_modifications[2];
unsigned int pps_id;
const uint8_t *intra_pcm_ptr;
int16_t *dc_val_base;
uint8_t *bipred_scratchpad;
uint8_t *edge_emu_buffer;
uint8_t (*top_borders[2])[(16 * 3) * 2];
int bipred_scratchpad_allocated;
int edge_emu_buffer_allocated;
int top_borders_allocated[2];
/**
* non zero coeff count cache.
* is 64 if not available.
*/
DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8];
/**
* Motion vector cache.
*/
DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5 * 8][2];
DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5 * 8];
DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5 * 8][2];
uint8_t direct_cache[5 * 8];
DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
///< as a DCT coefficient is int32_t in high depth, we need to reserve twice the space.
DECLARE_ALIGNED(16, int16_t, mb)[16 * 48 * 2];
DECLARE_ALIGNED(16, int16_t, mb_luma_dc)[3][16 * 2];
///< as mb is addressed by scantable[i] and scantable is uint8_t we can either
///< check that i is not too large or ensure that there is some unused stuff after mb
int16_t mb_padding[256 * 2];
uint8_t (*mvd_table[2])[2];
/**
* Cabac
*/
CABACContext cabac;
uint8_t cabac_state[1024];
int cabac_init_idc;
MMCO mmco[MAX_MMCO_COUNT];
int nb_mmco;
int explicit_ref_marking;
int frame_num;
int poc_lsb;
int delta_poc_bottom;
int delta_poc[2];
int curr_pic_num;
int max_pic_num;
} H264SliceContext;
/**
* H264Context
*/
typedef struct H264Context {
const AVClass *class;
AVCodecContext *avctx;
VideoDSPContext vdsp;
H264DSPContext h264dsp;
H264ChromaContext h264chroma;
H264QpelContext h264qpel;
H264Picture DPB[H264_MAX_PICTURE_COUNT];
H264Picture *cur_pic_ptr;
H264Picture cur_pic;
H264Picture last_pic_for_ec;
H264SliceContext *slice_ctx;
int nb_slice_ctx;
H2645Packet pkt;
int pixel_shift; ///< 0 for 8-bit H.264, 1 for high-bit-depth H.264
/* coded dimensions -- 16 * mb w/h */
int width, height;
int chroma_x_shift, chroma_y_shift;
/**
* Backup frame properties: needed, because they can be different
* between returned frame and last decoded frame.
**/
int backup_width;
int backup_height;
enum AVPixelFormat backup_pix_fmt;
int droppable;
int coded_picture_number;
int context_initialized;
int flags;
int workaround_bugs;
/* Set when slice threading is used and at least one slice uses deblocking
* mode 1 (i.e. across slice boundaries). Then we disable the loop filter
* during normal MB decoding and execute it serially at the end.
*/
int postpone_filter;
/*
* Set to 1 when the current picture is IDR, 0 otherwise.
*/
int picture_idr;
int8_t(*intra4x4_pred_mode);
H264PredContext hpc;
uint8_t (*non_zero_count)[48];
#define LIST_NOT_USED -1 // FIXME rename?
#define PART_NOT_AVAILABLE -2
/**
* block_offset[ 0..23] for frame macroblocks
* block_offset[24..47] for field macroblocks
*/
int block_offset[2 * (16 * 3)];
uint32_t *mb2b_xy; // FIXME are these 4 a good idea?
uint32_t *mb2br_xy;
int b_stride; // FIXME use s->b4_stride
uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1
// interlacing specific flags
int mb_aff_frame;
int picture_structure;
int first_field;
uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type
/* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0, 1, 2), 0x0? luma_cbp */
uint16_t *cbp_table;
/* chroma_pred_mode for i4x4 or i16x16, else 0 */
uint8_t *chroma_pred_mode_table;
uint8_t (*mvd_table[2])[2];
uint8_t *direct_table;
uint8_t zigzag_scan[16];
uint8_t zigzag_scan8x8[64];
uint8_t zigzag_scan8x8_cavlc[64];
uint8_t field_scan[16];
uint8_t field_scan8x8[64];
uint8_t field_scan8x8_cavlc[64];
uint8_t zigzag_scan_q0[16];
uint8_t zigzag_scan8x8_q0[64];
uint8_t zigzag_scan8x8_cavlc_q0[64];
uint8_t field_scan_q0[16];
uint8_t field_scan8x8_q0[64];
uint8_t field_scan8x8_cavlc_q0[64];
int mb_y;
int mb_height, mb_width;
int mb_stride;
int mb_num;
// =============================================================
// Things below are not used in the MB or more inner code
int nal_ref_idc;
int nal_unit_type;
/**
* Used to parse AVC variant of H.264
*/
int is_avc; ///< this flag is != 0 if codec is avc1
int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
int bit_depth_luma; ///< luma bit depth from sps to detect changes
int chroma_format_idc; ///< chroma format from sps to detect changes
H264ParamSets ps;
uint16_t *slice_table_base;
H264POCContext poc;
H264Ref default_ref[2];
H264Picture *short_ref[32];
H264Picture *long_ref[32];
H264Picture *delayed_pic[MAX_DELAYED_PIC_COUNT + 2]; // FIXME size?
int last_pocs[MAX_DELAYED_PIC_COUNT];
H264Picture *next_output_pic;
int next_outputed_poc;
/**
* memory management control operations buffer.
*/
MMCO mmco[MAX_MMCO_COUNT];
int nb_mmco;
int mmco_reset;
int explicit_ref_marking;
int long_ref_count; ///< number of actual long term references
int short_ref_count; ///< number of actual short term references
/**
* @name Members for slice based multithreading
* @{
*/
/**
* current slice number, used to initialize slice_num of each thread/context
*/
int current_slice;
/**
* Max number of threads / contexts.
* This is equal to AVCodecContext.thread_count unless
* multithreaded decoding is impossible, in which case it is
* reduced to 1.
*/
int max_contexts;
/**
* 1 if the single thread fallback warning has already been
* displayed, 0 otherwise.
*/
int single_decode_warning;
/** @} */
/**
* Complement sei_pic_struct
* SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced frames.
* However, soft telecined frames may have these values.
* This is used in an attempt to flag soft telecine progressive.
*/
int prev_interlaced_frame;
/**
* Are the SEI recovery points looking valid.
*/
int valid_recovery_point;
/**
* recovery_frame is the frame_num at which the next frame should
* be fully constructed.
*
* Set to -1 when not expecting a recovery point.
*/
int recovery_frame;
/**
* We have seen an IDR, so all the following frames in coded order are correctly
* decodable.
*/
#define FRAME_RECOVERED_IDR (1 << 0)
/**
* Sufficient number of frames have been decoded since a SEI recovery point,
* so all the following frames in presentation order are correct.
*/
#define FRAME_RECOVERED_SEI (1 << 1)
int frame_recovered; ///< Initial frame has been completely recovered
int has_recovery_point;
int missing_fields;
/* for frame threading, this is set to 1
* after finish_setup() has been called, so we cannot modify
* some context properties (which are supposed to stay constant between
* slices) anymore */
int setup_finished;
int cur_chroma_format_idc;
int cur_bit_depth_luma;
int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
int enable_er;
H264SEIContext sei;
AVBufferPool *qscale_table_pool;
AVBufferPool *mb_type_pool;
AVBufferPool *motion_val_pool;
AVBufferPool *ref_index_pool;
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
} H264Context;
extern const uint16_t ff_h264_mb_sizes[4];
/**
* Reconstruct bitstream slice_type.
*/
int ff_h264_get_slice_type(const H264SliceContext *sl);
/**
* Allocate tables.
* needs width/height
*/
int ff_h264_alloc_tables(H264Context *h);
int ff_h264_decode_ref_pic_list_reordering(H264SliceContext *sl, void *logctx);
int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl);
void ff_h264_remove_all_refs(H264Context *h);
/**
* Execute the reference picture marking (memory management control operations).
*/
int ff_h264_execute_ref_pic_marking(H264Context *h);
int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
const H2645NAL *nal, void *logctx);
void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl);
int ff_h264_decode_init(AVCodecContext *avctx);
void ff_h264_decode_init_vlc(void);
/**
* Decode a macroblock
* @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error
*/
int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl);
/**
* Decode a CABAC coded macroblock
* @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error
*/
int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl);
void ff_h264_init_cabac_states(const H264Context *h, H264SliceContext *sl);
void ff_h264_direct_dist_scale_factor(const H264Context *const h, H264SliceContext *sl);
void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *sl);
void ff_h264_pred_direct_motion(const H264Context *const h, H264SliceContext *sl,
int *mb_type);
void ff_h264_filter_mb_fast(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y,
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
unsigned int linesize, unsigned int uvlinesize);
void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y,
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
unsigned int linesize, unsigned int uvlinesize);
/*
* o-o o-o
* / / /
* o-o o-o
* ,---'
* o-o o-o
* / / /
* o-o o-o
*/
/* Scan8 organization:
* 0 1 2 3 4 5 6 7
* 0 DY y y y y y
* 1 y Y Y Y Y
* 2 y Y Y Y Y
* 3 y Y Y Y Y
* 4 y Y Y Y Y
* 5 DU u u u u u
* 6 u U U U U
* 7 u U U U U
* 8 u U U U U
* 9 u U U U U
* 10 DV v v v v v
* 11 v V V V V
* 12 v V V V V
* 13 v V V V V
* 14 v V V V V
* DY/DU/DV are for luma/chroma DC.
*/
#define LUMA_DC_BLOCK_INDEX 48
#define CHROMA_DC_BLOCK_INDEX 49
// This table must be here because scan8[constant] must be known at compiletime
static const uint8_t scan8[16 * 3 + 3] = {
4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8,
6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8,
4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8,
6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8,
4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8,
6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8,
4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8,
6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8,
4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8,
6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8,
4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8,
6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8,
0 + 0 * 8, 0 + 5 * 8, 0 + 10 * 8
};
static av_always_inline uint32_t pack16to32(unsigned a, unsigned b)
{
#if HAVE_BIGENDIAN
return (b & 0xFFFF) + (a << 16);
#else
return (a & 0xFFFF) + (b << 16);
#endif
}
static av_always_inline uint16_t pack8to16(unsigned a, unsigned b)
{
#if HAVE_BIGENDIAN
return (b & 0xFF) + (a << 8);
#else
return (a & 0xFF) + (b << 8);
#endif
}
/**
* Get the chroma qp.
*/
static av_always_inline int get_chroma_qp(const PPS *pps, int t, int qscale)
{
return pps->chroma_qp_table[t][qscale];
}
/**
* Get the predicted intra4x4 prediction mode.
*/
static av_always_inline int pred_intra_mode(const H264Context *h,
H264SliceContext *sl, int n)
{
const int index8 = scan8[n];
const int left = sl->intra4x4_pred_mode_cache[index8 - 1];
const int top = sl->intra4x4_pred_mode_cache[index8 - 8];
const int min = FFMIN(left, top);
ff_tlog(h->avctx, "mode:%d %d min:%d\n", left, top, min);
if (min < 0)
return DC_PRED;
else
return min;
}
static av_always_inline void write_back_intra_pred_mode(const H264Context *h,
H264SliceContext *sl)
{
int8_t *i4x4 = sl->intra4x4_pred_mode + h->mb2br_xy[sl->mb_xy];
int8_t *i4x4_cache = sl->intra4x4_pred_mode_cache;
AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4);
i4x4[4] = i4x4_cache[7 + 8 * 3];
i4x4[5] = i4x4_cache[7 + 8 * 2];
i4x4[6] = i4x4_cache[7 + 8 * 1];
}
static av_always_inline void write_back_non_zero_count(const H264Context *h,
H264SliceContext *sl)
{
const int mb_xy = sl->mb_xy;
uint8_t *nnz = h->non_zero_count[mb_xy];
uint8_t *nnz_cache = sl->non_zero_count_cache;
AV_COPY32(&nnz[ 0], &nnz_cache[4 + 8 * 1]);
AV_COPY32(&nnz[ 4], &nnz_cache[4 + 8 * 2]);
AV_COPY32(&nnz[ 8], &nnz_cache[4 + 8 * 3]);
AV_COPY32(&nnz[12], &nnz_cache[4 + 8 * 4]);
AV_COPY32(&nnz[16], &nnz_cache[4 + 8 * 6]);
AV_COPY32(&nnz[20], &nnz_cache[4 + 8 * 7]);
AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]);
AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]);
if (!h->chroma_y_shift) {
AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]);
AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]);
AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]);
AV_COPY32(&nnz[44], &nnz_cache[4 + 8 * 14]);
}
}
static av_always_inline void write_back_motion_list(const H264Context *h,
H264SliceContext *sl,
int b_stride,
int b_xy, int b8_xy,
int mb_type, int list)
{
int16_t(*mv_dst)[2] = &h->cur_pic.motion_val[list][b_xy];
int16_t(*mv_src)[2] = &sl->mv_cache[list][scan8[0]];
AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0);
AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1);
AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2);
AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3);
if (CABAC(h)) {
uint8_t (*mvd_dst)[2] = &sl->mvd_table[list][FMO ? 8 * sl->mb_xy
: h->mb2br_xy[sl->mb_xy]];
uint8_t(*mvd_src)[2] = &sl->mvd_cache[list][scan8[0]];
if (IS_SKIP(mb_type)) {
AV_ZERO128(mvd_dst);
} else {
AV_COPY64(mvd_dst, mvd_src + 8 * 3);
AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8 * 0);
AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8 * 1);
AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8 * 2);
}
}
{
int8_t *ref_index = &h->cur_pic.ref_index[list][b8_xy];
int8_t *ref_cache = sl->ref_cache[list];
ref_index[0 + 0 * 2] = ref_cache[scan8[0]];
ref_index[1 + 0 * 2] = ref_cache[scan8[4]];
ref_index[0 + 1 * 2] = ref_cache[scan8[8]];
ref_index[1 + 1 * 2] = ref_cache[scan8[12]];
}
}
static av_always_inline void write_back_motion(const H264Context *h,
H264SliceContext *sl,
int mb_type)
{
const int b_stride = h->b_stride;
const int b_xy = 4 * sl->mb_x + 4 * sl->mb_y * h->b_stride; // try mb2b(8)_xy
const int b8_xy = 4 * sl->mb_xy;
if (USES_LIST(mb_type, 0)) {
write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 0);
} else {
fill_rectangle(&h->cur_pic.ref_index[0][b8_xy],
2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
}
if (USES_LIST(mb_type, 1))
write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 1);
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) {
if (IS_8X8(mb_type)) {
uint8_t *direct_table = &h->direct_table[4 * sl->mb_xy];
direct_table[1] = sl->sub_mb_type[1] >> 1;
direct_table[2] = sl->sub_mb_type[2] >> 1;
direct_table[3] = sl->sub_mb_type[3] >> 1;
}
}
}
static av_always_inline int get_dct8x8_allowed(const H264Context *h, H264SliceContext *sl)
{
if (h->ps.sps->direct_8x8_inference_flag)
return !(AV_RN64A(sl->sub_mb_type) &
((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8) *
0x0001000100010001ULL));
else
return !(AV_RN64A(sl->sub_mb_type) &
((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_DIRECT2) *
0x0001000100010001ULL));
}
static inline int find_start_code(const uint8_t *buf, int buf_size,
int buf_index, int next_avc)
{
uint32_t state = -1;
buf_index = avpriv_find_start_code(buf + buf_index, buf + next_avc + 1, &state) - buf - 1;
return FFMIN(buf_index, buf_size);
}
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup);
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl);
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height);
int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
const H2645NAL *nal);
#define SLICE_SINGLETHREAD 1
#define SLICE_SKIPED 2
int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count);
int ff_h264_update_thread_context(AVCodecContext *dst,
const AVCodecContext *src);
void ff_h264_flush_change(H264Context *h);
void ff_h264_free_tables(H264Context *h);
void ff_h264_set_erpic(ERPicture *dst, H264Picture *src);
#endif /* AVCODEC_H264DEC_H */

View File

@ -27,7 +27,7 @@
#include "bit_depth_template.c"
#include "libavutil/common.h"
#include "h264dec.h"
#include "h264.h"
#include "h264idct.h"
void FUNCC(ff_h264_idct_add)(uint8_t *_dst, int16_t *_block, int stride)

View File

@ -37,6 +37,7 @@
#include "bytestream.h"
#include "hap.h"
#include "internal.h"
#include "memory.h"
#include "snappy.h"
#include "texturedsp.h"
#include "thread.h"

View File

@ -26,6 +26,7 @@
#include "libavutil/internal.h"
#include "cabac_functions.h"
#include "golomb.h"
#include "hevc.h"
#include "bit_depth_template.c"

View File

@ -25,7 +25,6 @@
#include "avcodec.h"
#include "canopus.h"
#include "get_bits.h"
#include "internal.h"
#include "hq_hqa.h"

View File

@ -24,9 +24,9 @@
#include <stdint.h>
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
#include "hq_hqadsp.h"
#include "vlc.h"
#define NUM_HQ_AC_ENTRIES 746
#define NUM_HQ_PROFILES 22

View File

@ -27,7 +27,7 @@
#include <stdint.h>
#include "libavutil/qsort.h"
#include "libavutil/common.h"
#include"libavutil/common.h"
#include "avcodec.h"
#include "huffman.h"

View File

@ -865,10 +865,8 @@ static void decode_delta_j(uint8_t *dst,
for (g = 0; g < groups; g++) {
offset = bytestream2_get_be16(&gb);
if (cols * bpp == 0 || bytestream2_get_bytes_left(&gb) < cols * bpp) {
av_log(NULL, AV_LOG_ERROR, "cols*bpp is invalid (%d*%d)", cols, bpp);
if (bytestream2_get_bytes_left(&gb) < 1)
return;
}
if (kludge_j)
offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j;
@ -913,10 +911,8 @@ static void decode_delta_j(uint8_t *dst,
for (d = 0; d < bpp; d++) {
unsigned noffset = offset + (r * pitch) + d * planepitch;
if (!bytes || bytestream2_get_bytes_left(&gb) < bytes) {
av_log(NULL, AV_LOG_ERROR, "bytes %d is invalid", bytes);
if (bytestream2_get_bytes_left(&gb) < 1)
return;
}
for (b = 0; b < bytes; b++) {
uint8_t value = bytestream2_get_byte(&gb);
@ -1381,15 +1377,13 @@ static void decode_delta_l(uint8_t *dst,
bytestream2_init(&dgb, buf + 2 * poff0, buf_end - (buf + 2 * poff0));
bytestream2_init(&ogb, buf + 2 * poff1, buf_end - (buf + 2 * poff1));
while (bytestream2_peek_be16(&ogb) != 0xFFFF && bytestream2_get_bytes_left(&ogb) >= 4) {
while ((bytestream2_peek_be16(&ogb)) != 0xFFFF && bytestream2_get_bytes_left(&ogb) >= 4) {
uint32_t offset = bytestream2_get_be16(&ogb);
int16_t cnt = bytestream2_get_be16(&ogb);
uint16_t data;
offset = ((2 * offset) / planepitch_byte) * pitch + ((2 * offset) % planepitch_byte) + k * planepitch;
if (cnt < 0) {
if (bytestream2_get_bytes_left(&dgb) < 2)
break;
bytestream2_seek_p(&pb, offset, SEEK_SET);
cnt = -cnt;
data = bytestream2_get_be16(&dgb);
@ -1398,8 +1392,6 @@ static void decode_delta_l(uint8_t *dst,
bytestream2_skip_p(&pb, dstpitch - 2);
}
} else {
if (bytestream2_get_bytes_left(&dgb) < 2*cnt)
break;
bytestream2_seek_p(&pb, offset, SEEK_SET);
for (i = 0; i < cnt; i++) {
data = bytestream2_get_be16(&dgb);

View File

@ -24,9 +24,8 @@
* Intel Indeo 2 decoder.
*/
#include "libavutil/attributes.h"
#define BITSTREAM_READER_LE
#include "libavutil/attributes.h"
#include "avcodec.h"
#include "get_bits.h"
#include "indeo2data.h"

View File

@ -26,6 +26,7 @@
#define IR2_CODES 143
static const uint16_t ir2_codes[IR2_CODES][2] = {
#ifdef BITSTREAM_READER_LE
{ 0x0000, 3 }, { 0x0004, 3 }, { 0x0006, 3 }, { 0x0001, 5 },
{ 0x0009, 5 }, { 0x0019, 5 }, { 0x000D, 5 }, { 0x001D, 5 },
{ 0x0023, 6 }, { 0x0013, 6 }, { 0x0033, 6 }, { 0x000B, 6 },
@ -62,6 +63,44 @@ static const uint16_t ir2_codes[IR2_CODES][2] = {
{ 0x003B, 6 }, { 0x0047, 8 }, { 0x00C7, 8 }, { 0x0017, 8 },
{ 0x00D7, 8 }, { 0x0077, 8 }, { 0x010F, 9 }, { 0x004F, 9 },
{ 0x01CF, 9 }, { 0x00AF, 9 }, { 0x016F, 9 },
#else
{ 0x0000, 3 }, { 0x0001, 3 }, { 0x0003, 3 }, { 0x0010, 5 },
{ 0x0012, 5 }, { 0x0013, 5 }, { 0x0016, 5 }, { 0x0017, 5 },
{ 0x0031, 6 }, { 0x0032, 6 }, { 0x0033, 6 }, { 0x0034, 6 },
{ 0x0035, 6 }, { 0x0036, 6 }, { 0x00E0, 8 }, { 0x00E1, 8 },
{ 0x00E4, 8 }, { 0x00E5, 8 }, { 0x00E6, 8 }, { 0x00E7, 8 },
{ 0x00E9, 8 }, { 0x00EA, 8 }, { 0x00EC, 8 }, { 0x00ED, 8 },
{ 0x00EF, 8 }, { 0x01E0, 9 }, { 0x01E2, 9 }, { 0x01E3, 9 },
{ 0x01E5, 9 }, { 0x01E6, 9 }, { 0x01E8, 9 }, { 0x01E9, 9 },
{ 0x01EB, 9 }, { 0x01EC, 9 }, { 0x01EE, 9 }, { 0x01EF, 9 },
{ 0x03E0, 10 }, { 0x03E1, 10 }, { 0x03E2, 10 }, { 0x03E3, 10 },
{ 0x03E4, 10 }, { 0x03E5, 10 }, { 0x03E6, 10 }, { 0x03E7, 10 },
{ 0x03E8, 10 }, { 0x03E9, 10 }, { 0x03EA, 10 }, { 0x03EB, 10 },
{ 0x03EC, 10 }, { 0x03ED, 10 }, { 0x03EE, 10 }, { 0x03EF, 10 },
{ 0x1F80, 13 }, { 0x1F81, 13 }, { 0x1F82, 13 }, { 0x1F83, 13 },
{ 0x1F84, 13 }, { 0x1F85, 13 }, { 0x1F86, 13 }, { 0x1F87, 13 },
{ 0x1F88, 13 }, { 0x1F89, 13 }, { 0x1F8A, 13 }, { 0x1F8B, 13 },
{ 0x1F8C, 13 }, { 0x1F8D, 13 }, { 0x1F8E, 13 }, { 0x1F8F, 13 },
{ 0x1F90, 13 }, { 0x1F91, 13 }, { 0x1F92, 13 }, { 0x1F93, 13 },
{ 0x1F94, 13 }, { 0x1F95, 13 }, { 0x1F96, 13 }, { 0x1F97, 13 },
{ 0x1F98, 13 }, { 0x1F99, 13 }, { 0x1F9A, 13 }, { 0x1F9B, 13 },
{ 0x1F9C, 13 }, { 0x1F9D, 13 }, { 0x1F9E, 13 }, { 0x1F9F, 13 },
{ 0x1FA0, 13 }, { 0x1FA1, 13 }, { 0x1FA2, 13 }, { 0x1FA3, 13 },
{ 0x1FA4, 13 }, { 0x1FA5, 13 }, { 0x1FA6, 13 }, { 0x1FA7, 13 },
{ 0x1FA8, 13 }, { 0x1FA9, 13 }, { 0x1FAA, 13 }, { 0x1FAB, 13 },
{ 0x1FAC, 13 }, { 0x1FAD, 13 }, { 0x1FAE, 13 }, { 0x1FAF, 13 },
{ 0x1FB0, 13 }, { 0x1FB1, 13 }, { 0x1FB2, 13 }, { 0x1FB3, 13 },
{ 0x1FB4, 13 }, { 0x1FB5, 13 }, { 0x1FB6, 13 }, { 0x1FB7, 13 },
{ 0x1FB8, 13 }, { 0x1FB9, 13 }, { 0x1FBA, 13 }, { 0x1FBB, 13 },
{ 0x1FBC, 13 }, { 0x1FBD, 13 }, { 0x1FBE, 13 }, { 0x1FBF, 13 },
{ 0x3F80, 14 }, { 0x3F81, 14 }, { 0x3F82, 14 }, { 0x3F83, 14 },
{ 0x3F84, 14 }, { 0x3F85, 14 }, { 0x3F86, 14 }, { 0x3F87, 14 },
{ 0x3F88, 14 }, { 0x3F89, 14 }, { 0x3F8A, 14 }, { 0x0002, 3 },
{ 0x0011, 5 }, { 0x0014, 5 }, { 0x0015, 5 }, { 0x0030, 6 },
{ 0x0037, 6 }, { 0x00E2, 8 }, { 0x00E3, 8 }, { 0x00E8, 8 },
{ 0x00EB, 8 }, { 0x00EE, 8 }, { 0x01E1, 9 }, { 0x01E4, 9 },
{ 0x01E7, 9 }, { 0x01EA, 9 }, { 0x01ED, 9 },
#endif
};
static const uint8_t ir2_delta_table[4][256] = {

View File

@ -30,10 +30,10 @@
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
#include "indeo4data.h"
#include "internal.h"
#include "ivi.h"
#include "ivi_dsp.h"
#include "indeo4data.h"
#include "internal.h"
#define IVI4_PIC_SIZE_ESC 7

View File

@ -19,9 +19,8 @@
*/
#include "libavutil/intreadwrite.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "internal.h"

View File

@ -39,12 +39,11 @@
#include <string.h>
#include "libavutil/intreadwrite.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "bytestream.h"
#include "get_bits.h"
#include "hpeldsp.h"
#define BITSTREAM_READER_LE
#include "get_bits.h"
#include "internal.h"
#define PALETTE_COUNT 256

View File

@ -116,7 +116,7 @@ static av_cold int x8_vlc_init(void)
#undef init_or_vlc
if (offset != sizeof(table) / sizeof(VLC_TYPE) / 2) {
av_log(NULL, AV_LOG_ERROR, "table size %"SIZE_SPECIFIER" does not match needed %i\n",
av_log(NULL, AV_LOG_ERROR, "table size %zd does not match needed %i\n",
sizeof(table) / sizeof(VLC_TYPE) / 2, offset);
return AVERROR_INVALIDDATA;
}

Some files were not shown because too many files have changed in this diff Show More