UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
libavcodec_test.cpp
Go to the documentation of this file.
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#include "config_unix.h"
4#include "config_win32.h"
5#endif
6
7#if defined HAVE_LAVC
8
9#include <list>
10#include <string>
11#include <tuple>
12
14#include "unit_common.h"
15#include "video_codec.h"
16
17using std::get;
18using std::list;
19using std::make_tuple;
20using std::string;
21using std::tuple;
22
23extern "C" decoder_t (*testable_get_decoder_from_uv_to_uv)(codec_t in, enum AVPixelFormat av, codec_t *out);
24
25extern "C" int libavcodec_test_get_decoder_from_uv_to_uv();
26
27int libavcodec_test_get_decoder_from_uv_to_uv()
28{
29 using namespace std::string_literals;
30
31 // testing mostly sanity - if the straightforward conversion is selected
32 list<tuple<codec_t, codec_t, decoder_t, string, AVPixelFormat>> expected_decoders {
33 make_tuple(RG48, RG48, &vc_memcpy, "vc_memcpy"s, AV_PIX_FMT_YUV444P16LE),
34 make_tuple(RGB, RGB, get_decoder_from_to(RGB, RGB), "vc_copylineRGB"s, AV_PIX_FMT_RGB24),
35 make_tuple(BGR, RGB, get_decoder_from_to(BGR, RGB), "vc_copylineBGRtoRGB"s, AV_PIX_FMT_RGB24),
36 make_tuple(BGR, BGR, &vc_memcpy, "vc_memcpy"s, AV_PIX_FMT_BGR24),
37 make_tuple(RG48, RG48, &vc_memcpy, "vc_memcpy"s, AV_PIX_FMT_RGB48LE),
38 };
39
40 for (auto & test_case : expected_decoders) {
42 decoder_t dec = testable_get_decoder_from_uv_to_uv(get<0>(test_case), get<4>(test_case), &out);
43 ASSERT_EQUAL_MESSAGE("Expected intermediate "s + get_codec_name(get<1>(test_case)) + " for UG decoder for "s
44 + get_codec_name(get<0>(test_case)) + " to "s + av_get_pix_fmt_name(get<4>(test_case)), get<1>(test_case), out);
45 ASSERT_EQUAL_MESSAGE("Expected UG decoder "s + get<3>(test_case) + " for "s + get_codec_name(get<0>(test_case)) + " to "s
46 + av_get_pix_fmt_name(get<4>(test_case)), (decoder_t) get<2>(test_case), dec);
47 }
48 return 0;
49}
50
51#endif // defined HAVE_LAVC
const char * get_codec_name(codec_t codec)
enum AVCodecID av
Definition lavc_common.c:64
decoder_t get_decoder_from_to(codec_t in, codec_t out)
decoder_func_t * decoder_t
Definition pixfmt_conv.h:96
decoder_func_t vc_memcpy
dummy conversion - ptr to it returned if no conversion needed
decoder_t(* testable_get_decoder_from_uv_to_uv)(codec_t in, enum AVPixelFormat av, codec_t *out)
codec_t
Definition types.h:65
@ RGB
RGB 8-bit (packed into 24-bit word)
Definition types.h:80
@ VIDEO_CODEC_NONE
dummy color spec
Definition types.h:66
@ BGR
8-bit BGR
Definition types.h:88
@ RG48
16-bit RGB little-endian (RlRhGl...)
Definition types.h:95
#define ASSERT_EQUAL_MESSAGE(msg, expected, actual)
Definition unit_common.h:53