Browse Source

hxxx_helper: provide picture left/top crop info

pull/162/head
Francois Cartegnie 4 years ago
parent
commit
7923ce4e00
  1. 3
      modules/codec/hxxx_helper.c
  2. 1
      modules/codec/hxxx_helper.h
  3. 5
      modules/codec/hxxx_helper_testdec.c
  4. 7
      modules/codec/omxil/mediacodec.c
  5. 9
      modules/codec/videotoolbox/decoder.c
  6. 7
      modules/hw/nvdec/nvdec.c

3
modules/codec/hxxx_helper.c

@ -810,17 +810,20 @@ h264_helper_get_current_sps(const struct hxxx_helper *hh)
int
hxxx_helper_get_current_picture_size(const struct hxxx_helper *hh,
unsigned *p_ox, unsigned *p_oy,
unsigned *p_w, unsigned *p_h,
unsigned *p_vw, unsigned *p_vh)
{
if(hh->i_codec == VLC_CODEC_H264)
{
*p_ox = *p_oy = 0;
const struct hxxx_helper_nal *hsps = h264_helper_get_current_sps(hh);
if (hsps && h264_get_picture_size(hsps->h264_sps, p_w, p_h, p_vw, p_vh))
return VLC_SUCCESS;
}
else if(hh->i_codec == VLC_CODEC_HEVC)
{
*p_ox = *p_oy = 0;
const struct hxxx_helper_nal *hsps = &hh->hevc.sps_list[hh->hevc.i_current_sps];
if(hsps && hsps->hevc_sps && hevc_get_picture_size(hsps->hevc_sps, p_w, p_h, p_vw, p_vh))
return VLC_SUCCESS;

1
modules/codec/hxxx_helper.h

@ -112,6 +112,7 @@ block_t * hxxx_helper_get_extradata_chain(const struct hxxx_helper *hh);
block_t * hxxx_helper_get_extradata_block(const struct hxxx_helper *hh);
int hxxx_helper_get_current_picture_size(const struct hxxx_helper *hh,
unsigned *p_ox, unsigned *p_oy,
unsigned *p_w, unsigned *p_h,
unsigned *p_vw, unsigned *p_vh);

5
modules/codec/hxxx_helper_testdec.c

@ -68,12 +68,15 @@ DecodeBlock(decoder_t *dec, block_t *block)
dec->fmt_out.video.color_range = full_range;
}
unsigned width, height, vis_width, vis_height;
unsigned offx, offy, width, height, vis_width, vis_height;
ret = hxxx_helper_get_current_picture_size(&sys->hh,
&offx, &offy,
&width, &height,
&vis_width, &vis_height);
if (ret == VLC_SUCCESS)
{
dec->fmt_out.video.i_x_offset = offx;
dec->fmt_out.video.i_y_offset = offy;
dec->fmt_out.video.i_width =
dec->fmt_out.video.i_visible_width = vis_width;
dec->fmt_out.video.i_height =

7
modules/codec/omxil/mediacodec.c

@ -131,6 +131,7 @@ typedef struct decoder_sys_t
struct android_picture_ctx apic_ctxs[MAX_PIC];
void *p_surface, *p_jsurface;
unsigned i_angle;
unsigned i_input_offset_x, i_input_offset_y;
unsigned i_input_width, i_input_height;
unsigned i_input_visible_width, i_input_visible_height;
unsigned int i_stride, i_slice_height;
@ -269,14 +270,16 @@ static void HXXXInitSize(decoder_t *p_dec, bool *p_size_changed)
{
decoder_sys_t *p_sys = p_dec->p_sys;
struct hxxx_helper *hh = &p_sys->video.hh;
unsigned i_w, i_h, i_vw, i_vh;
if(hxxx_helper_get_current_picture_size(hh, &i_w, &i_h, &i_vw, &i_vh)
unsigned i_ox, i_oy, i_w, i_h, i_vw, i_vh;
if(hxxx_helper_get_current_picture_size(hh, &i_ox, &i_oy, &i_w, &i_h, &i_vw, &i_vh)
== VLC_SUCCESS)
{
*p_size_changed = (i_w != p_sys->video.i_input_width
|| i_h != p_sys->video.i_input_height
|| i_vw != p_sys->video.i_input_visible_width
|| i_vh != p_sys->video.i_input_visible_height);
p_sys->video.i_input_offset_x = i_ox;
p_sys->video.i_input_offset_y = i_oy;
p_sys->video.i_input_width = i_w;
p_sys->video.i_input_height = i_h;
p_sys->video.i_input_visible_width = i_vw;

9
modules/codec/videotoolbox/decoder.c

@ -561,12 +561,15 @@ static bool ConfigureVoutH264(decoder_t *p_dec)
if (!p_dec->fmt_in->video.i_visible_width || !p_dec->fmt_in->video.i_visible_height)
{
unsigned i_width, i_height, i_vis_width, i_vis_height;
unsigned i_offset_x, i_offset_y, i_width, i_height, i_vis_width, i_vis_height;
if (VLC_SUCCESS ==
hxxx_helper_get_current_picture_size(&h264ctx->hh,
&i_offset_x, &i_offset_y,
&i_width, &i_height,
&i_vis_width, &i_vis_height))
{
p_dec->fmt_out.video.i_x_offset = i_offset_x;
p_dec->fmt_out.video.i_y_offset = i_offset_y;
p_dec->fmt_out.video.i_visible_width = i_vis_width;
p_dec->fmt_out.video.i_width = vlc_align(i_width, VT_ALIGNMENT);
p_dec->fmt_out.video.i_visible_height = i_vis_height;
@ -596,10 +599,10 @@ static bool VideoToolboxNeedsToRestartH264(decoder_t *p_dec,
struct vt_h264_context *h264ctx = p_sys->p_codec_context;
const struct hxxx_helper *hh = &h264ctx->hh;
unsigned w, h, vw, vh;
unsigned ox, oy, w, h, vw, vh;
int sarn, sard;
if (hxxx_helper_get_current_picture_size(hh, &w, &h, &vw, &vh) != VLC_SUCCESS)
if (hxxx_helper_get_current_picture_size(hh, &ox, &oy, &w, &h, &vw, &vh) != VLC_SUCCESS)
return true;
if (hxxx_helper_get_current_sar(hh, &sarn, &sard) != VLC_SUCCESS)

7
modules/hw/nvdec/nvdec.c

@ -884,8 +884,8 @@ static int OpenDecoder(vlc_object_t *p_this)
goto error;
cudaChroma = MapChomaIDC(i_chroma_idc);
unsigned i_w, i_h, i_vw, i_vh;
result = hxxx_helper_get_current_picture_size(&p_sys->hh, &i_w, &i_h, &i_vw, &i_vh);
unsigned i_ox, i_oy, i_w, i_h, i_vw, i_vh;
result = hxxx_helper_get_current_picture_size(&p_sys->hh, &i_ox, &i_oy, &i_w, &i_h, &i_vw, &i_vh);
if (result != VLC_SUCCESS)
goto error;
@ -911,6 +911,9 @@ static int OpenDecoder(vlc_object_t *p_this)
p_dec->fmt_out.video.i_width = vlc_align(i_w, OUTPUT_WIDTH_ALIGN);
p_dec->fmt_out.video.i_height = i_h;
p_dec->fmt_out.video.i_x_offset = i_ox;
p_dec->fmt_out.video.i_y_offset = i_oy;
if (!p_dec->fmt_in->video.i_visible_width || !p_dec->fmt_in->video.i_visible_height)
{
p_dec->fmt_out.video.i_visible_width = i_vw;

Loading…
Cancel
Save