1 /*****************************************************************************
2 * hxxx_helper_testdec.c: test decoder for hxxx_helper API
3 *****************************************************************************
4 * Copyright © 2020 VideoLAN, VLC authors and libbluray AUTHORS
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
25 #include <vlc_common.h>
26 #include <vlc_plugin.h>
27 #include <vlc_codec.h>
28 #include "hxxx_helper.h"
31 struct hxxx_helper hh
;
41 DecodeBlock(decoder_t
*dec
, block_t
*block
)
43 struct decoder_sys
*sys
= dec
->p_sys
;
46 return VLCDEC_SUCCESS
;
49 block
= sys
->hh
.pf_process_block(&sys
->hh
, block
, &config_changed
);
52 return VLCDEC_SUCCESS
;
57 video_color_primaries_t primaries
;
58 video_transfer_func_t transfer
;
59 video_color_space_t colorspace
;
60 video_color_range_t full_range
;
62 ret
= hxxx_helper_get_colorimetry(&sys
->hh
, &primaries
, &transfer
,
63 &colorspace
, &full_range
);
64 if (ret
== VLC_SUCCESS
)
66 dec
->fmt_out
.video
.primaries
= primaries
;
67 dec
->fmt_out
.video
.transfer
= transfer
;
68 dec
->fmt_out
.video
.space
= colorspace
;
69 dec
->fmt_out
.video
.color_range
= full_range
;
72 unsigned width
, height
, vis_width
, vis_height
;
73 ret
= hxxx_helper_get_current_picture_size(&sys
->hh
,
75 &vis_width
, &vis_height
);
76 if (ret
== VLC_SUCCESS
)
78 dec
->fmt_out
.video
.i_width
=
79 dec
->fmt_out
.video
.i_visible_width
= vis_width
;
80 dec
->fmt_out
.video
.i_height
=
81 dec
->fmt_out
.video
.i_visible_height
= vis_height
;
85 ret
= hxxx_helper_get_current_sar(&sys
->hh
, &sar_num
, &sar_den
);
86 if (ret
== VLC_SUCCESS
)
88 dec
->fmt_out
.video
.i_sar_num
= sar_num
;
89 dec
->fmt_out
.video
.i_sar_den
= sar_den
;
92 ret
= decoder_UpdateVideoOutput(dec
, NULL
);
94 return VLCDEC_ECRITICAL
;
99 return VLCDEC_SUCCESS
;
103 CloseDecoder(vlc_object_t
*this)
105 decoder_t
*dec
= (void *)this;
106 struct decoder_sys
*sys
= dec
->p_sys
;
108 hxxx_helper_clean(&sys
->hh
);
113 OpenDecoder(vlc_object_t
*this)
115 decoder_t
*dec
= (void *)this;
117 switch (dec
->fmt_in
.i_codec
)
126 struct decoder_sys
*sys
= malloc(sizeof(*sys
));
130 hxxx_helper_init(&sys
->hh
, this, dec
->fmt_in
.i_codec
,
131 var_InheritBool(this, "hxxx-helper-testdec-xvcC"));
133 int ret
= hxxx_helper_set_extra(&sys
->hh
, dec
->fmt_in
.p_extra
,
134 dec
->fmt_in
.i_extra
);
135 if (ret
!= VLC_SUCCESS
)
137 hxxx_helper_clean(&sys
->hh
);
143 dec
->pf_decode
= DecodeBlock
;
144 dec
->pf_flush
= Flush
;
146 dec
->fmt_out
.video
= dec
->fmt_in
.video
;
147 dec
->fmt_out
.video
.p_palette
= NULL
;
153 set_category(CAT_INPUT
)
154 set_subcategory(SUBCAT_INPUT_VCODEC
)
155 set_description(N_("hxxx test decoder"))
156 add_shortcut("hxxxhelper")
157 set_capability("video decoder", 0)
158 add_bool("hxxx-helper-testdec-xvcC", false, NULL
, NULL
, true)
159 set_callbacks(OpenDecoder
, CloseDecoder
)