Commit Graph

152 Commits

Author SHA1 Message Date
Andreas Rheinhardt 406c7fceeb fate/vcodec: Add speedhq tests
The vsynth3 tests are disabled, because the encoder produces garbage.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-06 15:00:21 +02:00
Andreas Rheinhardt 74d623914f avcodec/h263dec: Remove redundant code to set cur_pic_ptr
It is done later in ff_mpv_frame_start() (and nobody uses
current_picture_ptr between setting it in ff_mpv_frame_start()).

(The reason the vsynth*-h263-obmc ref files change is because
the call to ff_find_unused_picture() now happens after the older
pictures have been unreferenced in ff_mpv_frame_start(),
so that their slots in the picture array can be immediately
reused; the obmc code is somehow buggy and changes its output
depending on the earlier contents of the motion_val buffer.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-18 16:53:41 +02:00
Andreas Rheinhardt bc109a53c7 avcodec/mpegpicture: Move mb_var, mc_mb_var and mb_mean to MpegEncCtx
These tables are only used by encoders and only for the current picture;
ergo they need not be put into the picture at all, but rather into
the encoder's context. They also don't need to be refcounted,
because there is only one owner.

In contrast to this, the earlier code refcounts them which
incurs unnecessary overhead. These references are not unreferenced
in ff_mpeg_unref_picture() (they are kept in order to have something
like a buffer pool), so that several buffers are kept at the same
time, although only one is needed, thereby wasting memory.

The code also propagates references to other pictures not part of
the pictures array (namely the copy of the current/next/last picture
in the MpegEncContext which get references of their own). These
references are not unreferenced in ff_mpeg_unref_picture() (the
buffers are probably kept in order to have something like a pool),
yet if the current picture is a B-frame, it gets unreferenced
at the end of ff_mpv_encode_picture() and its slot in the picture
array will therefore be reused the next time; but the copy of the
current picture also still has its references and therefore
these buffers will be made duplicated in order to make them writable
in the next call to ff_mpv_encode_picture(). This is of course
unnecessary.

Finally, ff_find_unused_picture() is supposed to just return
any unused picture and the code is supposed to work with it;
yet for the vsynth*-mpeg4-adap tests the result depends upon
the content of these buffers; given that this patchset
changes the content of these buffers (the initial content is now
the state of these buffers after encoding the last frame;
before this patch the buffers used came from the last picture
that occupied the same slot in the picture array) their ref-files
needed to be changed. This points to a bug somewhere (if one removes
the initialization, one gets uninitialized reads in
adaptive_quantization in ratecontrol.c).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-09 19:17:22 +02:00
Wenbin Chen 76b33704b6 avcodec/mpegvideo_enc: Fix a chroma mb size error in sse_mb()
For 422 frames we should not use hard coded 8 to calculate mb size for
uv plane. Chroma shift should be taken into consideration to be
compatiple with different sampling format.

The error is reported by fate test when av_cpu_max_align() return 64
on the platform supporting AVX512. This is a hidden error and it is
exposed after commit 17a59a634c.

mpeg2enc has a mechanism to reuse frames. When it computes SSE (sum of
squared error) on current mb, reconstructed mb will be wrote to the
previous mb space, so that the memory can be saved. However if the align
is 64, the frame is shared in somewhere else, so the frame cannot be
reused and a new frame to store reconstrued data is created. Because the
height of mb is wrong when compute sse on 422 frame, starting from the
second line of macro block, changed data is read when frame is reused
(we need to read row 16 rather than row 8 if frame is 422), and unchanged
data is read when frame is not reused (a new frame is created so the
original frame will not be changed).

That is why commit 17a59a634c exposes this
issue, because it add av_cpu_max_align() and this function return 64 on
platform supporting AVX512 which lead to creating a frame in mpeg2enc,
and this lead to the different outputs.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-09 21:05:02 +02:00
Zhao Zhili 2e6e28ebc1 avformat/movenc: enable compressorname for mp4 mode
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-06-24 15:37:23 +08:00
Michael Niedermayer 366ef56f7f avcodec/ffv1enc: Eliminate float/double from find_best_state()
log2() remains, this can either be replaced by a integer implementation or the table
hardcoded if needed

Tested-by: Anton Khirnov <anton@khirnov.net>
Tested-by: Martin Storsjö <martin@martin.st>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-05-30 12:13:29 +02:00
Anton Khirnov 60f948dd55 tests/fate/vcodec: add tests for ffv1 2pass mode 2022-05-24 13:35:16 +02:00
Tomas Härdin 1cd8596ef4 libavcodec/cinepakenc: Mark no-skip frames as keyframes
Reset curframe whenever we generate a keyframe.
Use -g instead of -keyint_min.
2022-05-12 11:19:12 +02:00
Andreas Rheinhardt 155f68f7d1 tests/ref: Remove unused reference files
Accidentally resurrected in fc49f22c3b
and 7711f19eda,
forgotten in 6ebc71847e and
1a6a088f7c or never needed
(filter-aemphasis).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-03 04:18:06 +02:00
Mark Reid a48adcd136 libswcale/input: use more accurate planer rgb16 yuv conversions
These conversion appears to be exhibiting the same rounding error as the rgbf32 formats where.
I seperated the rounding value from the 16 and 128 offsets, I think it makes it a little more clear.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-06 17:56:52 +02:00
Jan Ekström 3838e8fc21 avformat/movenc: implement writing of the btrt box
This is utilized by various media ingests to figure out the bit
rate of the content you are pushing towards it, so write it for
video, audio and subtitle tracks in case at least one nonzero value
is available. It is only mentioned for timed metadata sample
descriptions in QTFF, so limit it only to ISOBMFF (MODE_MP4) mode.

Updates the FATE tests which have their results changed due to the
20 extra bytes being written per track.
2020-09-22 18:21:31 +03:00
Marton Balint 00117e28c1 avutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps
SMPTE 12M timecode can only count frames up to 39, because the tens-of-frames
value is stored in 2 bit. In order to resolve this 50/60 fps SMPTE timecode is
using the field bit (which is the same bit as the phase correction bit) to
signal the least significant bit of a 50/60 fps timecode. See SMPTE ST
12-1:2014 section 12.1.

Therefore we slightly change the format of the return value of
av_timecode_get_smpte_from_framenum and AV_FRAME_DATA_S12M_TIMECODE and start
using the previously unused Phase Correction bit as Field bit. (As the SMPTE
standard suggests)

We add 50/60 fps support to av_timecode_get_smpte_from_framenum by calling the
recently added av_timecode_get_smpte function in it which already handles this
properly.

This change affects the decklink indev and the DV and MXF muxers. MXF has no
fate test for 50/60fps content, DV does, therefore the changes.

MediaInfo (a recent version) confirms that half-frame timecode must be inserted
to DV. MXFInspect confirms valid timecode insertion to the System Item of MXF
files. For MXF, also see EBU R122.

Note that for DV the field flag is not used because in the HDV specs (SMPTE
370M) it is still defined as biphase mark polarity correction flag. So it
should not matter that the DV muxer overrides the field bit.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-09-13 17:51:57 +02:00
Gautam Ramakrishnan 341064d68a libavcodec/jpeg2000: fix tag tree reset
The implementation of the tag tree did not
set the correct reset value for the encoder.
This lead to inefficent tag tree being encoded.
This patch fixes the implementation of the
ff_tag_tree_zero() function.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Gautam Ramakrishnan f0e33119e4 libavcodec/j2kenc: Support for multiple layers
This patch allows setting a compression ratio and to
set multiple layers. The user has to input a compression
ratio for each layer.
The per layer compression ration can be set as follows:
-layer_rates "r1,r2,...rn"
for to create 'n' layers.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Michael Bradshaw 05039c1334 tests/ref/vsynth: fix fate colr changes (again)
Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
2020-04-13 13:34:49 -07:00
Michael Bradshaw 19a16330f4 tests/ref/vsynth: fix fate colr changes
Commit 9842fd3aaf stopped guessing colr
values.

Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
2020-04-13 12:59:06 -07:00
James Almer 245ace4e2d avformat/movenc: ensure we don't write the major brand as a compatible brand more than once
Signed-off-by: James Almer <jamrial@gmail.com>
2019-12-21 11:57:28 -03:00
James Almer 58ac760816 avformat/movenc: write the major brand also as the first compatible brand
Signed-off-by: James Almer <jamrial@gmail.com>
2019-12-21 11:57:28 -03:00
Michael Niedermayer 8d5f9daacd tests/ref/vsynth: add missing reference files, fix build 2019-11-13 23:34:56 +01:00
Baptiste Coudurier a1403032c8 avcodec/dvenc: support encoding dvcprohd 2019-11-13 09:08:43 -08:00
Marton Balint 397abca001 avformat/movenc: use unspecified language by default
English was used before.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-07-12 20:26:38 +02:00
Martin Vignali 26cf50404d avcodec/proresenc_aw : fix interlace encoding for unsafe height
fix the call of the unsafe version of slice encoding in interlace mode
fix padding line count in sub image with fill in interlace mode
2019-03-09 20:46:50 +01:00
Martin Vignali b38dd2d219 fate/proresenc_aw : add test for interlace and 444 encoding 2019-02-27 17:59:53 +01:00
Paul B Mahol 3d8d8c7199 avcodec/r210: use correct pixel format 2018-12-03 17:17:42 +01:00
Martin Vignali e832d769f4 avcodec/proresenc_aw : use for frame flag in the header the same value than the official encoder 2018-10-18 21:39:06 +02:00
Martin Vignali cea5e90bde avcodec/proresenc_aw : use qp close to the official encoder 2018-10-18 21:38:48 +02:00
Martin Vignali 1a45b12cdc avcodec/proresenc_aw : use AVframe primaries, transfert, colorspace for frame header instead of default (unknown, unknown, Rec601)
avoid color shift, on some decoding software
2018-10-18 21:38:44 +02:00
James Darnley 088b07427d fate: add more vc2 encoder tests 2018-07-18 11:32:20 +02:00
James Almer 0ff8f0b7b4 Merge commit '5be9939b46a6a4d3860a1b1a872aa50897095970'
* commit '5be9939b46a6a4d3860a1b1a872aa50897095970':
  fate: Add cinepak encoder vsynth tests

See d7f62f033c

Merged-by: James Almer <jamrial@gmail.com>
2017-11-07 18:35:34 -03:00
Mateusz f192f2f061 swscale: more accurate DITHER_COPY macro for full and limited range
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-10-23 23:00:05 +02:00
Michael Niedermayer abaeeb3ce0 avcodec/dvenc: Change quantizer dead zone default to 7
This improves the quality and reduces the "blocking" in flat areas

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-08 19:39:21 +02:00
Diego Biurrun 5be9939b46 fate: Add cinepak encoder vsynth tests 2017-07-05 13:05:54 +02:00
Rostislav Pehlivanov 45eeb1f785 mjpegenc: enable optimal huffman coding by default
As it gives excellent encoding gains at an insignificant speed increase
and passes fate without problems, it should now be safe to enable by
default.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-04-09 00:00:39 +01:00
Paul B Mahol e1940d2458 avcodec/dnxhd_parser: take into account compressed frame size and skip it
Fixes #6214 and vsynth1-dnxhd-720p-hr-lb.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-03-24 15:44:01 +01:00
Tobias Rapp 205b8fd078 avcodec: estimate output bitrate for uncompressed video codecs
Allows to get a more realistic total bitrate (and estimated file size)
in avi_write_header. Previously a static default value of 200k was
assumed.

Adds an internal helper function for bitrate guessing.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-17 11:55:16 +01:00
Jerry Jiang 884506dfe2 Implement optimal huffman encoding for (M)JPEG.
> seems to break
> make fate-vsynth1-mjpeg-444

Fixed.
2017-02-08 13:59:53 +00:00
Mark Reid eb5f4b1482 tests/fate/vcodec: add dnxhr mov tests
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-22 12:59:54 +02:00
Michael Niedermayer 0d98686fde fate: Add RGB48 FFV1 test
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-16 23:14:11 +02:00
Mark Reid 44ac2b9b08 tests/fate/vcodec: add dnxhr edge tests
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-12 23:26:33 +02:00
Mark Reid 6108cb2ce3 tests/fate: add dnxhr encoding tests
added sws_flags flags and tested against x86_32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-24 12:31:07 +02:00
Luca Barbato fe6e5cbea7 ffv1: Remove version 2 and mark version 3 as non-experimental
The encoder produces bitstream compatible with the current specification
and version 2 is set as reserved (non-standardizable).
2016-06-29 07:21:07 +02:00
Christophe Gisquet 01938585f4 vc2: fate tests 2016-05-08 19:50:39 +01:00
Mats Peterson ed5d295a69 lavf/riffenc: Improve spec compliance; Fix WMP playback of AVI with xxpc chunks
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-13 13:12:13 +01:00
Mats Peterson f680c8e41a tests/ref/vsynth: Remove unused file
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-13 13:12:12 +01:00
Anton Khirnov 9200514ad8 lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2016-02-23 17:01:58 +01:00
Mats Peterson a51d82b85c lavf/avienc: Add palette after BITMAPINFOHEADER
lavf/riffenc: Write space for palette
tests/ref/vsynth: Update 1 bpp files for pal8

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-21 03:30:50 +01:00
Michael Niedermayer 9dd4dcde9c avformat/avienc: Use avi_write_packet_internal() to store raw rgb in a more spec compliant way
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-18 21:26:50 +01:00
Michael Niedermayer 23261e6001 sws/output: fix ordered dither threshold for mono output
This makes sure that white stays white and black black

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-10 17:22:26 +01:00
Michael Niedermayer 6ffac5d33d avcodec/rawdec: Switch to monowhite if there is no palette & bpp=1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-31 04:36:53 +01:00
Mats Peterson b34c9d1b9d lavc/rawdec: Use AV_PIX_FMT_PAL8 for raw 1 bpp video in AVI
From
https://msdn.microsoft.com/en-us/library/windows/desktop/dd318229%28v=vs.85%29.aspx:

"If biCompression equals BI_RGB and the bitmap uses 8 bpp or less, the
bitmap has a color table immediatelly following the BITMAPINFOHEADER
structure. The color table consists of an array of RGBQUAD values. The
size of the array is given by the biClrUsed member. If biClrUsed is
zero, the array contains the maximum number of colors for the given
bitdepth; that is, 2^biBitCount colors."

Nothing about "monochrome" here. Unfortunately, pal8 to monow conversion
seems a bit flaky, but that's another story.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-29 14:52:30 +01:00