[vlc-commits] [Git][videolan/vlc][master] 17 commits: libvlc: hardcode the bits per pixel for ARGB stride
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Sep 4 05:42:03 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
7bbd08dc by Steve Lhomme at 2023-09-04T07:07:03+02:00
libvlc: hardcode the bits per pixel for ARGB stride
It may not even correspond to the padding we may use with a real picture.
- - - - -
0e588e6f by Steve Lhomme at 2023-09-04T07:07:03+02:00
vlc_fourcc: add a function to get bits per pixel per chroma
This is the average usable bits per pixel, not related to individual pixels.
- - - - -
87a429dc by Steve Lhomme at 2023-09-04T07:07:03+02:00
screen: report the average bits per pixel using vlc_fourcc_GetChromaBPP()
- - - - -
a427c3c9 by Steve Lhomme at 2023-09-04T07:07:03+02:00
avcodec: set bits_per_coded_sample using vlc_fourcc_GetChromaBPP()
bits_per_coded_sample should be 15 for VLC_CODEC_RGB15 which is what
this function returns.
- - - - -
4208836f by Steve Lhomme at 2023-09-04T07:07:03+02:00
dmo: fix rounding the bytes necessary for the image
If biBitCount is 15, we need 2 bytes per pixel, even for a 1x1 output.
- - - - -
afa87655 by Steve Lhomme at 2023-09-04T07:07:03+02:00
dmo: factorize code to set input FourCC
- - - - -
736554e2 by Steve Lhomme at 2023-09-04T07:07:03+02:00
dmo: use the bit depth corresponding to the output chroma
It doesn't matter what bit depth is on the input.
- - - - -
df7dfadc by Steve Lhomme at 2023-09-04T07:07:03+02:00
dmo: use plane_CopyPixels to copy pixels
- - - - -
ecc5d311 by Steve Lhomme at 2023-09-04T07:07:03+02:00
access/bluray: assume the background is I420
And pass the video_format, not the whole es_format_t when filling it.
- - - - -
d597a972 by Steve Lhomme at 2023-09-04T07:07:03+02:00
vout/drm: use vlc_fourcc_GetChromaBPP to get bits per pixels
VLC_CODEC_RGB15 will report 15 and will be rounded to 16 as before.
- - - - -
32a577ca by Steve Lhomme at 2023-09-04T07:07:03+02:00
smem: keep the bits per pixel
vlc_fourcc_GetChromaBPP() gets the same value as is in fmt->i_bits_per_pixel.
- - - - -
45f1ac00 by Steve Lhomme at 2023-09-04T07:07:03+02:00
smem: don't keep a whole es_format_t
es_format_Copy can copy a lot of things we don't need.
- - - - -
a2a0c87b by Steve Lhomme at 2023-09-04T07:07:03+02:00
xwd: use plane_CopyPixels to copy the RGB buffer
It will copy less than needed if the output size doesn't fit.
- - - - -
e6fd74f8 by Steve Lhomme at 2023-09-04T07:07:03+02:00
screen/win32: cache the pitch of the DIB section
We only need to compute it once.
- - - - -
5025f0cf by Steve Lhomme at 2023-09-04T07:07:03+02:00
mmal: use vlc_fourcc_GetChromaBPP to get bits per pixels
- - - - -
cf2613a7 by Steve Lhomme at 2023-09-04T07:08:04+02:00
modules: remove write-only video format i_bits_per_pixel
- - - - -
1d46d8b7 by Steve Lhomme at 2023-09-04T07:08:04+02:00
vlc_es: remove unused i_bits_per_pixel from video_format_t
- - - - -
30 changed files:
- include/vlc_es.h
- include/vlc_fourcc.h
- lib/picture.c
- modules/access/bluray.c
- modules/access/screen/mac.c
- modules/access/screen/screen.c
- modules/access/screen/wayland.c
- modules/access/screen/win32.c
- modules/access/vnc.c
- modules/codec/arib/libaribcaption.c
- modules/codec/avcodec/video.c
- modules/codec/dmo/dmo.c
- modules/codec/kate.c
- modules/codec/libass.c
- modules/codec/qsv.c
- modules/codec/schroedinger.c
- modules/codec/xwd.c
- modules/codec/zvbi.c
- modules/demux/avformat/demux.c
- modules/demux/mp4/essetup.c
- modules/demux/ogg.c
- modules/demux/rawvid.c
- modules/demux/smooth/playlist/CodecParameters.cpp
- modules/hw/mmal/converter.c
- modules/hw/mmal/mmal_picture.c
- modules/hw/nvdec/nvdec.c
- modules/stream_out/smem.c
- modules/text_renderer/svg.c
- modules/video_output/drm/buffers.c
- src/misc/es_format.c
Changes:
=====================================
include/vlc_es.h
=====================================
@@ -362,8 +362,6 @@ struct video_format_t
unsigned int i_visible_width; /**< width of visible area */
unsigned int i_visible_height; /**< height of visible area */
- unsigned int i_bits_per_pixel; /**< number of bits per pixel */
-
unsigned int i_sar_num; /**< sample/pixel aspect ratio */
unsigned int i_sar_den;
=====================================
include/vlc_fourcc.h
=====================================
@@ -782,5 +782,25 @@ typedef struct {
*/
VLC_API const vlc_chroma_description_t * vlc_fourcc_GetChromaDescription( vlc_fourcc_t fourcc ) VLC_USED;
+/**
+ * Get the average usable bits per pixel for a chroma.
+ * \note it may return 0 for opaque or compressed vlc_fourcc_t
+ */
+static inline unsigned vlc_fourcc_GetChromaBPP( vlc_fourcc_t fourcc )
+{
+ const vlc_chroma_description_t *desc = vlc_fourcc_GetChromaDescription( fourcc );
+ if (desc == NULL || desc->plane_count == 0)
+ return 0;
+
+ unsigned bpp = 0;
+ for (size_t plane=0; plane < desc->plane_count; plane++)
+ {
+ bpp += 2 * desc->pixel_bits * desc->p[plane].h.num * desc->p[plane].w.num /
+ (desc->p[plane].h.den * desc->p[plane].w.den);
+ }
+ bpp /= 2; // for chromas that might have 4*4 denominators
+ return bpp;
+}
+
#endif /* _VLC_FOURCC_H */
=====================================
lib/picture.c
=====================================
@@ -190,7 +190,7 @@ libvlc_picture_type_t libvlc_picture_type( const libvlc_picture_t* pic )
unsigned int libvlc_picture_get_stride( const libvlc_picture_t *pic )
{
assert( pic->type == libvlc_picture_Argb );
- return pic->fmt.i_width * pic->fmt.i_bits_per_pixel / 8;
+ return pic->fmt.i_width * 4;
}
unsigned int libvlc_picture_get_width( const libvlc_picture_t* pic )
=====================================
modules/access/bluray.c
=====================================
@@ -591,12 +591,12 @@ static void FindMountPoint(char **file)
static void bluraySendBackgroundImage(vlc_object_t *p_obj,
es_out_t *p_dst_out,
es_out_id_t *p_es,
- const es_format_t *p_fmt)
+ const video_format_t *p_fmt)
{
msg_Info(p_obj, "Start background");
- block_t *p_block = block_Alloc(p_fmt->video.i_width * p_fmt->video.i_height *
- p_fmt->video.i_bits_per_pixel / 8);
+ assert(p_fmt->i_chroma == VLC_CODEC_I420);
+ block_t *p_block = block_Alloc(p_fmt->i_width * p_fmt->i_height * 3 / 2);
if (!p_block) {
msg_Err(p_obj, "Error allocating block for background video");
return;
@@ -606,9 +606,10 @@ static void bluraySendBackgroundImage(vlc_object_t *p_obj,
p_block->i_dts = p_block->i_pts = vlc_tick_now() + VLC_TICK_FROM_MS(40);
uint8_t *p = p_block->p_buffer;
- memset(p, 0, p_fmt->video.i_width * p_fmt->video.i_height);
- p += p_fmt->video.i_width * p_fmt->video.i_height;
- memset(p, 0x80, p_fmt->video.i_width * p_fmt->video.i_height / 2);
+ // Set I420 black
+ memset(p, 0, p_fmt->i_width * p_fmt->i_height);
+ p += p_fmt->i_width * p_fmt->i_height;
+ memset(p, 0x80, p_fmt->i_width * p_fmt->i_height / 2);
es_out_SetPCR(p_dst_out, p_block->i_dts - VLC_TICK_FROM_MS(40));
es_out_Control(p_dst_out, ES_OUT_SET_ES, p_es);
@@ -1498,7 +1499,7 @@ static int bluray_esOutControl(es_out_t *p_out, input_source_t *in, int i_query,
bluraySendBackgroundImage(esout_priv->p_obj,
esout_priv->p_dst_out,
esout_priv->overlay.p_video_es,
- &fmt);
+ &fmt.video);
}
es_format_Clean(&fmt);
}
=====================================
modules/access/screen/mac.c
=====================================
@@ -130,7 +130,6 @@ int screen_InitCapture(demux_t *p_demux)
p_sys->fmt.video.i_width = rect.size.width;
p_sys->fmt.video.i_visible_height =
p_sys->fmt.video.i_height = rect.size.height;
- p_sys->fmt.video.i_bits_per_pixel = 32;
p_sys->fmt.video.i_chroma = VLC_CODEC_RGB32;
p_sys->fmt.video.i_rmask = 0x00ff0000;
p_sys->fmt.video.i_gmask = 0x0000ff00;
=====================================
modules/access/screen/screen.c
=====================================
@@ -174,7 +174,7 @@ static int Open( vlc_object_t *p_this )
msg_Dbg( p_demux, "screen width: %i, height: %i, depth: %i",
p_sys->fmt.video.i_width, p_sys->fmt.video.i_height,
- p_sys->fmt.video.i_bits_per_pixel );
+ vlc_fourcc_GetChromaBPP(p_sys->fmt.video.i_chroma) );
#ifdef SCREEN_SUBSCREEN
if( p_sys->i_left >= p_sys->fmt.video.i_width
=====================================
modules/access/screen/wayland.c
=====================================
@@ -123,7 +123,6 @@ static void output_mode_cb(void *data, struct wl_output *output,
es_format_Init(&fmt, VIDEO_ES, VLC_CODEC_RGB32);
fmt.video.i_chroma = VLC_CODEC_RGB32;
- fmt.video.i_bits_per_pixel = 32;
fmt.video.i_sar_num = fmt.video.i_sar_den = 1;
fmt.video.i_frame_rate = lroundf(1000.f * sys->rate);
fmt.video.i_frame_rate_base = 1000;
=====================================
modules/access/screen/win32.c
=====================================
@@ -49,6 +49,7 @@ typedef struct
HGDIOBJ hgdi_backup;
POINT ptl; /* Coordinates of the primary display's top left, when the origin
* is taken to be the top left of the entire virtual screen */
+ size_t pitch;
int i_fragment_size;
int i_fragment;
@@ -151,6 +152,8 @@ int screen_InitCaptureGDI( demux_t *p_demux )
p_sys->fmt.video.transfer = TRANSFER_FUNC_SRGB;
p_sys->fmt.video.color_range = COLOR_RANGE_FULL;
+ p_data->pitch = ( ( ( screen_width * i_bits_per_pixel ) + 31 ) & ~31 ) >> 3;
+
p_data->ptl.x = - GetSystemMetrics( SM_XVIRTUALSCREEN );
p_data->ptl.y = - GetSystemMetrics( SM_YVIRTUALSCREEN );
@@ -193,7 +196,8 @@ struct block_sys_t
static void CaptureBlockRelease( block_t *p_block )
{
- DeleteObject( ((struct block_sys_t *)p_block)->hbmp );
+ struct block_sys_t *p_sys = container_of(p_block, struct block_sys_t, self);
+ DeleteObject( p_sys->hbmp );
free( p_block );
}
@@ -219,7 +223,7 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
p_data->bmi.bmiHeader.biWidth = p_sys->fmt.video.i_width;
p_data->bmi.bmiHeader.biHeight = - p_sys->fmt.video.i_height;
p_data->bmi.bmiHeader.biPlanes = 1;
- p_data->bmi.bmiHeader.biBitCount = p_sys->fmt.video.i_bits_per_pixel;
+ p_data->bmi.bmiHeader.biBitCount = p_data->pitch * 8 / p_sys->fmt.video.i_width;
p_data->bmi.bmiHeader.biCompression = BI_RGB;
p_data->bmi.bmiHeader.biSizeImage = 0;
p_data->bmi.bmiHeader.biXPelsPerMeter = 0;
@@ -265,9 +269,7 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
goto error;
/* Fill all fields */
- int i_stride =
- ( ( ( ( p_sys->fmt.video.i_width * p_sys->fmt.video.i_bits_per_pixel ) + 31 ) & ~31 ) >> 3 );
- i_buffer = i_stride * p_sys->fmt.video.i_height;
+ i_buffer = p_data->pitch * p_sys->fmt.video.i_height;
block_Init( &p_block->self, &CaptureBlockCallbacks, p_buffer, i_buffer );
p_block->hbmp = hbmp;
@@ -291,8 +293,7 @@ static void RenderCursor( demux_t *p_demux, int i_x, int i_y,
return;
/* Bitmaps here created by CreateDIBSection: stride rounded up to the nearest DWORD */
- p_sys->dst.p[ 0 ].i_pitch = p_sys->dst.p[ 0 ].i_visible_pitch =
- ( ( ( ( p_sys->fmt.video.i_width * p_sys->fmt.video.i_bits_per_pixel ) + 31 ) & ~31 ) >> 3 );
+ p_sys->dst.p[ 0 ].i_pitch = p_sys->dst.p[ 0 ].i_visible_pitch = p_data->pitch;
if( !p_data->p_blend )
{
=====================================
modules/access/vnc.c
=====================================
@@ -230,7 +230,6 @@ static rfbBool mallocFrameBufferHandler( rfbClient* p_client )
fmt.video.i_frame_rate_base = 1000;
fmt.video.i_frame_rate = 1000 * p_sys->f_fps;
- fmt.video.i_bits_per_pixel = i_bits_per_pixel;
fmt.video.i_sar_num = fmt.video.i_sar_den = 1;
/* declare the new es */
=====================================
modules/codec/arib/libaribcaption.c
=====================================
@@ -167,7 +167,6 @@ static void SubpictureUpdate(subpicture_t *p_subpic,
fmt.i_rmask = 0;
fmt.i_gmask = 0;
fmt.i_bmask = 0;
- fmt.i_bits_per_pixel = 0;
fmt.i_x_offset = 0;
fmt.i_y_offset = 0;
=====================================
modules/codec/avcodec/video.c
=====================================
@@ -418,7 +418,7 @@ static int OpenVideoCodec( decoder_t *p_dec )
ctx->coded_height = p_dec->fmt_in->video.i_height;
}
- ctx->bits_per_coded_sample = p_dec->fmt_in->video.i_bits_per_pixel;
+ ctx->bits_per_coded_sample = vlc_fourcc_GetChromaBPP(p_dec->fmt_in->video.i_chroma);
p_sys->pix_fmt = AV_PIX_FMT_NONE;
cc_Init( &p_sys->cc );
=====================================
modules/codec/dmo/dmo.c
=====================================
@@ -361,12 +361,14 @@ static int DecOpen( decoder_t *p_dec )
if( p_dec->fmt_in->i_extra )
memcpy( &p_vih[1], p_dec->fmt_in->p_extra, p_dec->fmt_in->i_extra );
+ vlc_fourcc_t fcc = p_dec->fmt_in->i_original_fourcc ?
+ p_dec->fmt_in->i_original_fourcc : p_dec->fmt_in->i_codec;
+
p_bih = &p_vih->bmiHeader;
- p_bih->biCompression = p_dec->fmt_in->i_original_fourcc ?
- p_dec->fmt_in->i_original_fourcc : p_dec->fmt_in->i_codec;
+ p_bih->biCompression = fcc;
p_bih->biWidth = p_dec->fmt_in->video.i_width;
p_bih->biHeight = p_dec->fmt_in->video.i_height;
- p_bih->biBitCount = p_dec->fmt_in->video.i_bits_per_pixel;
+ p_bih->biBitCount = vlc_fourcc_GetChromaBPP(fcc);
p_bih->biPlanes = 1;
p_bih->biSize = i_size - sizeof(VIDEOINFOHEADER) + sizeof(*p_bih);
@@ -377,8 +379,7 @@ static int DecOpen( decoder_t *p_dec )
dmo_input_type.majortype = MEDIATYPE_Video;
dmo_input_type.subtype = dmo_input_type.majortype;
- dmo_input_type.subtype.Data1 = p_dec->fmt_in->i_original_fourcc ?
- p_dec->fmt_in->i_original_fourcc: p_dec->fmt_in->i_codec;
+ dmo_input_type.subtype.Data1 = fcc;
dmo_input_type.formattype = FORMAT_VideoInfo;
dmo_input_type.bFixedSizeSamples = 0;
dmo_input_type.bTemporalCompression = 1;
@@ -433,7 +434,6 @@ static int DecOpen( decoder_t *p_dec )
BITMAPINFOHEADER *p_bih;
DMO_MEDIA_TYPE mt;
unsigned i_chroma = VLC_CODEC_YUYV;
- int i_bpp = 16;
int i = 0;
/* Find out which chroma to use */
@@ -442,7 +442,6 @@ static int DecOpen( decoder_t *p_dec )
if( mt.subtype.Data1 == VLC_CODEC_YV12 )
{
i_chroma = mt.subtype.Data1;
- i_bpp = 12;
DMOFreeMediaType( &mt );
break;
}
@@ -451,7 +450,6 @@ static int DecOpen( decoder_t *p_dec )
IsEqualGUID( &mt.subtype, &MEDIASUBTYPE_RGB24 ) )
{
i_chroma = VLC_CODEC_RGB24;
- i_bpp = 24;
}
DMOFreeMediaType( &mt );
@@ -460,7 +458,6 @@ static int DecOpen( decoder_t *p_dec )
p_dec->fmt_out.i_codec = i_chroma == VLC_CODEC_YV12 ? VLC_CODEC_I420 : i_chroma;
p_dec->fmt_out.video.i_width = p_dec->fmt_in->video.i_width;
p_dec->fmt_out.video.i_height = p_dec->fmt_in->video.i_height;
- p_dec->fmt_out.video.i_bits_per_pixel = i_bpp;
/* If an aspect-ratio was specified in the input format then force it */
if( p_dec->fmt_in->video.i_sar_num > 0 &&
@@ -478,10 +475,10 @@ static int DecOpen( decoder_t *p_dec )
p_bih = &p_vih->bmiHeader;
p_bih->biCompression = i_chroma == VLC_CODEC_RGB24 ? BI_RGB : i_chroma;
p_bih->biHeight *= -1;
- p_bih->biBitCount = p_dec->fmt_out.video.i_bits_per_pixel;
+ p_bih->biBitCount = vlc_fourcc_GetChromaBPP(i_chroma);
p_bih->biSizeImage = p_dec->fmt_in->video.i_width *
p_dec->fmt_in->video.i_height *
- (p_dec->fmt_in->video.i_bits_per_pixel + 7) / 8;
+ ((p_bih->biBitCount + 7) / 8);
p_bih->biPlanes = 1; /* http://msdn.microsoft.com/en-us/library/dd183376%28v=vs.85%29.aspx */
p_bih->biSize = sizeof(*p_bih);
@@ -1062,10 +1059,6 @@ static int EncoderSetVideoType( encoder_t *p_enc, IMediaObject *p_dmo )
VIDEOINFOHEADER vih, *p_vih;
BITMAPINFOHEADER *p_bih;
- /* FIXME */
- p_enc->fmt_in.video.i_bits_per_pixel =
- p_enc->fmt_out.video.i_bits_per_pixel = 12;
-
/* Enumerate input format (for debug output) */
i = 0;
while( !IMediaObject_GetInputType( p_dmo, 0, i++, &dmo_type ) )
@@ -1090,9 +1083,9 @@ static int EncoderSetVideoType( encoder_t *p_enc, IMediaObject *p_dmo )
p_bih->biCompression = VLC_CODEC_I420;
p_bih->biWidth = p_enc->fmt_in.video.i_visible_width;
p_bih->biHeight = p_enc->fmt_in.video.i_visible_height;
- p_bih->biBitCount = p_enc->fmt_in.video.i_bits_per_pixel;
+ p_bih->biBitCount = vlc_fourcc_GetChromaBPP(VLC_CODEC_I420);
p_bih->biSizeImage = p_enc->fmt_in.video.i_visible_width *
- p_enc->fmt_in.video.i_visible_height * p_enc->fmt_in.video.i_bits_per_pixel /8;
+ p_enc->fmt_in.video.i_visible_height * ((p_bih->biBitCount + 7) /8);
p_bih->biPlanes = 3;
p_bih->biSize = sizeof(*p_bih);
@@ -1456,31 +1449,32 @@ static block_t *EncodeBlock( encoder_t *p_enc, void *p_data )
if( p_enc->fmt_out.i_cat == VIDEO_ES )
{
/* Get picture data */
- int i_plane, i_line, i_width, i_src_stride;
picture_t *p_pic = (picture_t *)p_data;
uint8_t *p_dst;
- int i_buffer = p_enc->fmt_in.video.i_visible_width *
- p_enc->fmt_in.video.i_visible_height *
- p_enc->fmt_in.video.i_bits_per_pixel / 8;
+ const vlc_chroma_description_t *dsc = vlc_fourcc_GetChromaDescription(p_pic->format.i_chroma);
+ assert(dsc != NULL);
+ size_t i_buffer = 0;
+ plane_t dst_planes[PICTURE_PLANE_MAX];
+ for (unsigned plane=0; plane < dsc->plane_count; plane++)
+ {
+ dst_planes[plane].i_pitch = dst_planes[plane].i_visible_pitch =
+ (p_enc->fmt_in.video.i_visible_width * dsc->pixel_size *
+ dsc->p[plane].w.num * dsc->p[plane].h.num) /
+ (dsc->p[plane].w.den * dsc->p[plane].h.den);
+ dst_planes[plane].i_lines = dst_planes[plane].i_visible_lines = p_enc->fmt_in.video.i_visible_height;
+ i_buffer += dst_planes[plane].i_pitch * dst_planes[plane].i_lines;
+ }
p_block_in = block_Alloc( i_buffer );
/* Copy picture stride by stride */
p_dst = p_block_in->p_buffer;
- for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
+ for(int i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{
- uint8_t *p_src = p_pic->p[i_plane].p_pixels;
- i_width = p_pic->p[i_plane].i_visible_pitch;
- i_src_stride = p_pic->p[i_plane].i_pitch;
-
- for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines;
- i_line++ )
- {
- memcpy( p_dst, p_src, i_width );
- p_dst += i_width;
- p_src += i_src_stride;
- }
+ dst_planes[i_plane].p_pixels = p_dst;
+ plane_CopyPixels(&dst_planes[i_plane], &p_pic->p[i_plane]);
+ p_dst += dst_planes[i_plane].i_pitch * dst_planes[i_plane].i_lines;
}
i_pts = p_pic->date;
=====================================
modules/codec/kate.c
=====================================
@@ -859,7 +859,6 @@ static void TigerUpdateSubpicture( subpicture_t *p_subpic,
/* create a full frame region - this will also tell Tiger the size of the frame */
video_format_t fmt = *p_fmt_dst;
fmt.i_chroma = VLC_CODEC_RGBA;
- fmt.i_bits_per_pixel = 0;
fmt.i_width =
fmt.i_visible_width = p_fmt_src->i_width;
fmt.i_height =
=====================================
modules/codec/libass.c
=====================================
@@ -433,7 +433,6 @@ static int SubpictureValidate( subpicture_t *p_subpic,
video_format_t fmt = *p_fmt_dst;
fmt.i_chroma = VLC_CODEC_RGBA;
- fmt.i_bits_per_pixel = 0;
fmt.i_x_offset = 0;
fmt.i_y_offset = 0;
if( b_fmt_src || b_fmt_dst )
=====================================
modules/codec/qsv.c
=====================================
@@ -622,7 +622,6 @@ static int Open(vlc_object_t *this)
enc->fmt_in.video.i_rmask = 0;
enc->fmt_in.video.i_gmask = 0;
enc->fmt_in.video.i_bmask = 0;
- enc->fmt_in.video.i_bits_per_pixel = 12;
// require aligned pictures on input, a filter may be added before the encoder
enc->fmt_in.video.i_width = sys->params.mfx.FrameInfo.Width;
enc->fmt_in.video.i_height = sys->params.mfx.FrameInfo.Height;
=====================================
modules/codec/schroedinger.c
=====================================
@@ -1021,17 +1021,14 @@ static bool SetEncChromaFormat( encoder_t *p_enc, uint32_t i_codec )
switch( i_codec ) {
case VLC_CODEC_I420:
p_enc->fmt_in.i_codec = i_codec;
- p_enc->fmt_in.video.i_bits_per_pixel = 12;
p_sys->p_format->chroma_format = SCHRO_CHROMA_420;
break;
case VLC_CODEC_I422:
p_enc->fmt_in.i_codec = i_codec;
- p_enc->fmt_in.video.i_bits_per_pixel = 16;
p_sys->p_format->chroma_format = SCHRO_CHROMA_422;
break;
case VLC_CODEC_I444:
p_enc->fmt_in.i_codec = i_codec;
- p_enc->fmt_in.video.i_bits_per_pixel = 24;
p_sys->p_format->chroma_format = SCHRO_CHROMA_444;
break;
default:
=====================================
modules/codec/xwd.c
=====================================
@@ -96,29 +96,18 @@ static int Decode (decoder_t *dec, block_t *block)
dec->fmt_in->video.i_sar_num,
dec->fmt_in->video.i_sar_den);
- const size_t copy = dec->fmt_out.video.i_width
- * (dec->fmt_out.video.i_bits_per_pixel / 8);
- const uint32_t pitch = ntohl(hdr->bytes_per_line);
-
- /* Build picture */
- if (pitch < copy
- || (block->i_buffer / pitch) < dec->fmt_out.video.i_height)
- goto drop;
-
if (decoder_UpdateVideoFormat(dec))
goto drop;
pic = decoder_NewPicture(dec);
if (pic == NULL)
goto drop;
- const uint8_t *in = block->p_buffer;
- uint8_t *out = pic->p->p_pixels;
- for (unsigned i = 0; i < dec->fmt_out.video.i_height; i++)
- {
- memcpy(out, in, copy);
- in += pitch;
- out += pic->p->i_pitch;
- }
+ plane_t plane;
+ plane.p_pixels = block->p_buffer;
+ plane.i_pitch = plane.i_visible_pitch = ntohl(hdr->bytes_per_line);
+ plane.i_lines = dec->fmt_out.video.i_height;
+ plane.i_visible_lines = dec->fmt_out.video.i_visible_height;
+ plane_CopyPixels(pic->p, &plane);
pic->date = block->i_pts;
pic->b_progressive = true;
=====================================
modules/codec/zvbi.c
=====================================
@@ -538,15 +538,10 @@ static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt,
}
video_format_Init(&fmt, b_text ? VLC_CODEC_TEXT : VLC_CODEC_RGBA);
- if( b_text )
- {
- fmt.i_bits_per_pixel = 0;
- }
- else
+ if( !b_text )
{
fmt.i_width = fmt.i_visible_width = i_columns * 12;
fmt.i_height = fmt.i_visible_height = i_rows * 10;
- fmt.i_bits_per_pixel = 32;
fmt.i_sar_num = fmt.i_sar_den = 0; /* let the vout set the correct AR */
}
fmt.i_x_offset = fmt.i_y_offset = 0;
=====================================
modules/demux/avformat/demux.c
=====================================
@@ -495,7 +495,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
es_format_Init( &es_fmt, VIDEO_ES, fcc );
es_fmt.i_original_fourcc = CodecTagToFourcc( cp->codec_tag );
- es_fmt.video.i_bits_per_pixel = cp->bits_per_coded_sample;
/* Special case for raw video data */
if( cp->codec_id == AV_CODEC_ID_RAWVIDEO )
{
=====================================
modules/demux/mp4/essetup.c
=====================================
@@ -290,7 +290,6 @@ int SetupVideoES( demux_t *p_demux, const mp4_track_t *p_track, const MP4_Box_t
p_fmt->video.i_width = p_vide->i_width;
p_fmt->video.i_height = p_vide->i_height;
- p_fmt->video.i_bits_per_pixel = p_vide->i_depth;
/* fall on display size */
if( p_fmt->video.i_width <= 0 )
@@ -722,7 +721,6 @@ int SetupVideoES( demux_t *p_demux, const mp4_track_t *p_track, const MP4_Box_t
}
p_fmt->video.color_range = p_data->i_fullrange ? COLOR_RANGE_FULL : COLOR_RANGE_LIMITED;
- p_fmt->video.i_bits_per_pixel = p_data->i_bit_depth;
CopyExtradata( p_data->p_codec_init_data,
p_data->i_codec_init_datasize,
@@ -766,7 +764,6 @@ int SetupVideoES( demux_t *p_demux, const mp4_track_t *p_track, const MP4_Box_t
p_fmt->video.i_visible_width = p_fmt->video.i_width;
p_fmt->video.i_height = BOXDATA(p_strf)->bmiHeader.biHeight;
p_fmt->video.i_visible_height =p_fmt->video.i_height;
- p_fmt->video.i_bits_per_pixel = BOXDATA(p_strf)->bmiHeader.biBitCount;
CopyExtradata( BOXDATA(p_strf)->p_extra,
BOXDATA(p_strf)->i_extra,
p_fmt );
=====================================
modules/demux/ogg.c
=====================================
@@ -1866,11 +1866,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
p_stream->fmt.video.i_frame_rate = num;
p_stream->fmt.video.i_frame_rate_base = den;
date_Init( &p_stream->dts, num, den );
- p_stream->fmt.video.i_bits_per_pixel =
- GetWLE((oggpacket.packet+182));
- if( !p_stream->fmt.video.i_bits_per_pixel )
- /* hack, FIXME */
- p_stream->fmt.video.i_bits_per_pixel = 24;
+ unsigned bpp = GetWLE((oggpacket.packet+182));
p_stream->fmt.video.i_width =
GetDWLE((oggpacket.packet+176));
p_stream->fmt.video.i_height =
@@ -1886,7 +1882,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
p_stream->fmt.video.i_frame_rate_base,
p_stream->fmt.video.i_width,
p_stream->fmt.video.i_height,
- p_stream->fmt.video.i_bits_per_pixel);
+ bpp);
if ( !p_stream->fmt.video.i_frame_rate ||
!p_stream->fmt.video.i_frame_rate_base )
@@ -2018,7 +2014,6 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
date_Init( &p_stream->dts, num, den );
p_stream->fmt.video.i_frame_rate = num;
p_stream->fmt.video.i_frame_rate_base = den;
- p_stream->fmt.video.i_bits_per_pixel = st->bits_per_sample;
p_stream->fmt.video.i_width = st->sh.video.width;
p_stream->fmt.video.i_height = st->sh.video.height;
p_stream->fmt.video.i_visible_width =
@@ -2032,7 +2027,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
p_stream->fmt.video.i_frame_rate_base,
p_stream->fmt.video.i_width,
p_stream->fmt.video.i_height,
- p_stream->fmt.video.i_bits_per_pixel );
+ st->bits_per_sample );
}
/* Check for audio header (new format) */
else if( !strncmp( st->streamtype, "audio", 5 ) &&
=====================================
modules/demux/rawvid.c
=====================================
@@ -340,16 +340,16 @@ valid:
p_sys->fmt_video.video.i_frame_rate_base );
date_Set( &p_sys->pcr, VLC_TICK_0 );
- if( !p_sys->fmt_video.video.i_bits_per_pixel )
+ const vlc_chroma_description_t *dsc =
+ vlc_fourcc_GetChromaDescription(p_sys->fmt_video.video.i_chroma);
+ if (unlikely(dsc == NULL))
+ goto error;
+ if (dsc->plane_count == 0)
{
msg_Err( p_demux, "Unsupported chroma 0x%.8x (%4.4s)", i_chroma,
(char*)&i_chroma );
goto error;
}
- const vlc_chroma_description_t *dsc =
- vlc_fourcc_GetChromaDescription(p_sys->fmt_video.video.i_chroma);
- if (unlikely(dsc == NULL))
- goto error;
p_sys->frame_size = 0;
for (unsigned i=0; i<dsc->plane_count; i++)
{
=====================================
modules/demux/smooth/playlist/CodecParameters.cpp
=====================================
@@ -120,7 +120,6 @@ void CodecParameters::initAndFillEsFmt(es_format_t *fmt) const
else if( fmt->i_codec == VLC_FOURCC( 'W', 'V', 'C', '1' ) )
{
fmt->i_codec = VLC_CODEC_VC1;
-// fmt->video.i_bits_per_pixel = 0x18; // No clue why this was set in smooth streamfilter
}
FillExtradata(fmt, extradata);
=====================================
modules/hw/mmal/converter.c
=====================================
@@ -197,7 +197,7 @@ static void cma_buf_pool_deletez(cma_buf_pool_t ** const pp)
static MMAL_STATUS_T pic_to_format(MMAL_ES_FORMAT_T * const es_fmt, const picture_t * const pic)
{
- unsigned int bpp = (pic->format.i_bits_per_pixel + 7) >> 3;
+ unsigned int bpp = (vlc_fourcc_GetChromaBPP(pic->format.i_chroma) + 7) >> 3;
MMAL_VIDEO_FORMAT_T * const v_fmt = &es_fmt->es->video;
es_fmt->type = MMAL_ES_TYPE_VIDEO;
@@ -484,7 +484,7 @@ static MMAL_STATUS_T conv_set_output(filter_t * const p_filter, converter_sys_t
// Override default format width/height if we have a pic we need to match
if ((status = pic_to_format(sys->output->format, pic)) != MMAL_SUCCESS)
{
- msg_Err(p_filter, "Bad format desc: %4.4s, pic=%p, bits=%d", (const char*)&pic->format.i_chroma, (void*)pic, pic->format.i_bits_per_pixel);
+ msg_Err(p_filter, "Bad format desc: %4.4s, pic=%p, bits=%d", (const char*)&pic->format.i_chroma, (void*)pic, vlc_fourcc_GetChromaBPP(pic->format.i_chroma));
return status;
}
}
=====================================
modules/hw/mmal/mmal_picture.c
=====================================
@@ -1088,7 +1088,7 @@ MMAL_BUFFER_HEADER_T * hw_mmal_vzc_buf_from_pic(vzc_pool_ctl_t * const pc,
// ?? Round start offset as well as length
const video_format_t *const fmt = &pic->format;
- const unsigned int bpp = (fmt->i_bits_per_pixel + 7) >> 3;
+ const unsigned int bpp = (vlc_fourcc_GetChromaBPP(fmt->i_chroma) + 7) >> 3;
const unsigned int xl = (fmt->i_x_offset & ~15);
const unsigned int xr = (fmt->i_x_offset + fmt->i_visible_width + 15) & ~15;
const size_t dst_stride = (xr - xl) * bpp;
=====================================
modules/hw/nvdec/nvdec.c
=====================================
@@ -245,7 +245,6 @@ static int CUtoFMT(video_format_t *fmt, const CUVIDEOFORMAT *p_format)
// frame rate
fmt->i_frame_rate = p_format->frame_rate.numerator;
fmt->i_frame_rate_base = p_format->frame_rate.denominator;
- fmt->i_bits_per_pixel = i_bpp;
return VLC_SUCCESS;
}
@@ -964,7 +963,6 @@ static int OpenDecoder(vlc_object_t *p_this)
p_dec->fmt_out.video.i_sar_num = i_sar_num;
p_dec->fmt_out.video.i_sar_den = i_sar_den;
#undef ALIGN
- p_dec->fmt_out.video.i_bits_per_pixel = i_depth_luma;
p_dec->fmt_out.video.i_frame_rate = p_dec->fmt_in->video.i_frame_rate;
p_dec->fmt_out.video.i_frame_rate_base = p_dec->fmt_in->video.i_frame_rate_base;
=====================================
modules/stream_out/smem.c
=====================================
@@ -136,7 +136,17 @@ static int SendAudio( sout_stream_t *p_stream, void *id, block_t *p_buffer );
typedef struct
{
- es_format_t format;
+ enum es_format_category_e i_cat;
+ union {
+ struct {
+ uint8_t i_channels;
+ unsigned int i_rate;
+ } audio;
+ struct {
+ unsigned int i_width, i_height;
+ } video;
+ };
+ unsigned i_bitspersample;
void *p_data;
} sout_stream_id_sys_t;
@@ -284,39 +294,6 @@ static void *AddVideo( sout_stream_t *p_stream, const es_format_t *p_fmt )
{
char* psz_tmp;
sout_stream_id_sys_t *id;
- int i_bits_per_pixel;
-
- switch( p_fmt->i_codec )
- {
- case VLC_CODEC_RGB32:
- case VLC_CODEC_RGBA:
- case VLC_CODEC_ARGB:
- case VLC_CODEC_BGRA:
- case VLC_CODEC_ABGR:
- i_bits_per_pixel = 32;
- break;
- case VLC_CODEC_I444:
- case VLC_CODEC_RGB24:
- i_bits_per_pixel = 24;
- break;
- case VLC_CODEC_RGB16:
- case VLC_CODEC_RGB15:
- case VLC_CODEC_RGB8:
- case VLC_CODEC_I422:
- i_bits_per_pixel = 16;
- break;
- case VLC_CODEC_YV12:
- case VLC_CODEC_I420:
- i_bits_per_pixel = 12;
- break;
- case VLC_CODEC_RGBP:
- i_bits_per_pixel = 8;
- break;
- default:
- i_bits_per_pixel = 0;
- msg_Dbg( p_stream, "non raw video format detected (%4.4s), buffers will contain compressed video", (char *)&p_fmt->i_codec );
- break;
- }
id = calloc( 1, sizeof( sout_stream_id_sys_t ) );
if( !id )
@@ -326,8 +303,12 @@ static void *AddVideo( sout_stream_t *p_stream, const es_format_t *p_fmt )
id->p_data = (void *)( intptr_t )atoll( psz_tmp );
free( psz_tmp );
- es_format_Copy( &id->format, p_fmt );
- id->format.video.i_bits_per_pixel = i_bits_per_pixel;
+ id->i_cat = VIDEO_ES;
+ id->video.i_width = p_fmt->video.i_width;
+ id->video.i_height = p_fmt->video.i_height;
+ id->i_bitspersample = vlc_fourcc_GetChromaBPP(p_fmt->video.i_chroma);
+ if (id->i_bitspersample == 0)
+ msg_Dbg( p_stream, "non raw video format detected (%4.4s), buffers will contain compressed video", (char *)&p_fmt->i_codec );
return id;
}
@@ -351,8 +332,10 @@ static void *AddAudio( sout_stream_t *p_stream, const es_format_t *p_fmt )
id->p_data = (void *)( intptr_t )atoll( psz_tmp );
free( psz_tmp );
- es_format_Copy( &id->format, p_fmt );
- id->format.audio.i_bitspersample = i_bits_per_sample;
+ id->i_cat = AUDIO_ES;
+ id->audio.i_channels = p_fmt->audio.i_channels;
+ id->audio.i_rate = p_fmt->audio.i_rate;
+ id->i_bitspersample = i_bits_per_sample;
return id;
}
@@ -360,16 +343,15 @@ static void Del( sout_stream_t *p_stream, void *_id )
{
VLC_UNUSED( p_stream );
sout_stream_id_sys_t *id = (sout_stream_id_sys_t *)_id;
- es_format_Clean( &id->format );
free( id );
}
static int Send( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
{
sout_stream_id_sys_t *id = (sout_stream_id_sys_t *)_id;
- if ( id->format.i_cat == VIDEO_ES )
+ if ( id->i_cat == VIDEO_ES )
return SendVideo( p_stream, id, p_buffer );
- else if ( id->format.i_cat == AUDIO_ES )
+ if ( id->i_cat == AUDIO_ES )
return SendAudio( p_stream, id, p_buffer );
return VLC_SUCCESS;
}
@@ -395,8 +377,9 @@ static int SendVideo( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
memcpy( p_pixels, p_buffer->p_buffer, i_size );
/* Calling the postrender callback to tell the user his buffer is ready */
p_sys->pf_video_postrender_callback( id->p_data, p_pixels,
- id->format.video.i_width, id->format.video.i_height,
- id->format.video.i_bits_per_pixel, i_size, p_buffer->i_pts );
+ id->video.i_width, id->video.i_height,
+ id->i_bitspersample,
+ i_size, p_buffer->i_pts );
block_ChainRelease( p_buffer );
return VLC_SUCCESS;
}
@@ -410,14 +393,14 @@ static int SendAudio( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
int i_samples = 0;
i_size = p_buffer->i_buffer;
- if (id->format.audio.i_channels == 0)
+ if (id->audio.i_channels == 0)
{
msg_Warn( p_stream, "No buffer given!" );
block_ChainRelease( p_buffer );
return VLC_EGENERIC;
}
- i_samples = i_size / ( ( id->format.audio.i_bitspersample / 8 ) * id->format.audio.i_channels );
+ i_samples = i_size / ( ( id->i_bitspersample / 8 ) * id->audio.i_channels );
/* Calling the prerender callback to get user buffer */
p_sys->pf_audio_prerender_callback( id->p_data, &p_pcm_buffer, i_size );
if (!p_pcm_buffer)
@@ -431,8 +414,8 @@ static int SendAudio( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
memcpy( p_pcm_buffer, p_buffer->p_buffer, i_size );
/* Calling the postrender callback to tell the user his buffer is ready */
p_sys->pf_audio_postrender_callback( id->p_data, p_pcm_buffer,
- id->format.audio.i_channels, id->format.audio.i_rate, i_samples,
- id->format.audio.i_bitspersample, i_size, p_buffer->i_pts );
+ id->audio.i_channels, id->audio.i_rate, i_samples,
+ id->i_bitspersample, i_size, p_buffer->i_pts );
block_ChainRelease( p_buffer );
return VLC_SUCCESS;
}
=====================================
modules/text_renderer/svg.c
=====================================
@@ -252,7 +252,6 @@ static picture_t * svg_RenderPicture( filter_t *p_filter,
/* Create a new subpicture region */
video_format_t fmt;
video_format_Init( &fmt, VLC_CODEC_BGRA ); /* CAIRO_FORMAT_ARGB32 == VLC_CODEC_BGRA, go figure */
- fmt.i_bits_per_pixel = 32;
fmt.i_chroma = VLC_CODEC_BGRA;
fmt.i_width = fmt.i_visible_width = dim.width;
fmt.i_height = fmt.i_visible_height = dim.height;
=====================================
modules/video_output/drm/buffers.c
=====================================
@@ -82,7 +82,7 @@ picture_t *vlc_drm_dumb_alloc(struct vlc_logger *log, int fd,
struct drm_mode_create_dumb creq = {
.height = template.format.i_height,
.width = template.format.i_width,
- .bpp = (template.format.i_bits_per_pixel + 7) & ~7,
+ .bpp = (vlc_fourcc_GetChromaBPP(template.format.i_chroma) + 7) & ~7,
.flags = 0,
};
=====================================
src/misc/es_format.c
=====================================
@@ -90,104 +90,6 @@ void video_format_Setup( video_format_t *p_fmt, vlc_fourcc_t i_chroma,
vlc_ureduce( &p_fmt->i_sar_num, &p_fmt->i_sar_den,
i_sar_num, i_sar_den, 0 );
video_format_FixRgb( p_fmt );
-
- switch( p_fmt->i_chroma )
- {
- case VLC_CODEC_YUVA:
- p_fmt->i_bits_per_pixel = 32;
- break;
- case VLC_CODEC_YUV420A:
- p_fmt->i_bits_per_pixel = 20;
- break;
- case VLC_CODEC_YUV422A:
- p_fmt->i_bits_per_pixel = 24;
- break;
- case VLC_CODEC_I444:
- case VLC_CODEC_J444:
- p_fmt->i_bits_per_pixel = 24;
- break;
- case VLC_CODEC_I422:
- case VLC_CODEC_YUYV:
- case VLC_CODEC_YVYU:
- case VLC_CODEC_UYVY:
- case VLC_CODEC_YUV2:
- case VLC_CODEC_VYUY:
- case VLC_CODEC_J422:
- p_fmt->i_bits_per_pixel = 16;
- break;
- case VLC_CODEC_I440:
- case VLC_CODEC_J440:
- p_fmt->i_bits_per_pixel = 16;
- break;
- case VLC_CODEC_P010:
- p_fmt->i_bits_per_pixel = 15;
- break;
- case VLC_CODEC_P016:
- p_fmt->i_bits_per_pixel = 20;
- break;
- case VLC_CODEC_I411:
- case VLC_CODEC_YV12:
- case VLC_CODEC_I420:
- case VLC_CODEC_J420:
- case VLC_CODEC_NV12:
- p_fmt->i_bits_per_pixel = 12;
- break;
- case VLC_CODEC_YV9:
- case VLC_CODEC_I410:
- p_fmt->i_bits_per_pixel = 9;
- break;
- case VLC_CODEC_Y211:
- p_fmt->i_bits_per_pixel = 8;
- break;
- case VLC_CODEC_YUVP:
- p_fmt->i_bits_per_pixel = 8;
- break;
-
- case VLC_CODEC_RGB32:
- case VLC_CODEC_RGBA:
- case VLC_CODEC_ARGB:
- case VLC_CODEC_BGRA:
- case VLC_CODEC_ABGR:
- case VLC_CODEC_RGBX:
- case VLC_CODEC_XRGB:
- case VLC_CODEC_BGRX:
- case VLC_CODEC_XBGR:
- p_fmt->i_bits_per_pixel = 32;
- break;
- case VLC_CODEC_RGB24:
- p_fmt->i_bits_per_pixel = 24;
- break;
- case VLC_CODEC_RGB15:
- case VLC_CODEC_RGB16:
- p_fmt->i_bits_per_pixel = 16;
- break;
- case VLC_CODEC_RGB8:
- p_fmt->i_bits_per_pixel = 8;
- break;
-
- case VLC_CODEC_GREY:
- case VLC_CODEC_RGBP:
- p_fmt->i_bits_per_pixel = 8;
- break;
-
- case VLC_CODEC_GREY_10B:
- case VLC_CODEC_GREY_10L:
- p_fmt->i_bits_per_pixel = 10;
- break;
-
- case VLC_CODEC_GREY_12B:
- case VLC_CODEC_GREY_12L:
- p_fmt->i_bits_per_pixel = 12;
- break;
-
- case VLC_CODEC_XYZ12:
- p_fmt->i_bits_per_pixel = 48;
- break;
-
- default:
- p_fmt->i_bits_per_pixel = 0;
- break;
- }
}
void video_format_CopyCrop( video_format_t *p_dst, const video_format_t *p_src )
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/15fc2b8f97c8fe403af9a9dd6e0bb35ff1dd3ad2...1d46d8b7ce6220311198013f0172ff3af9e66dab
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/15fc2b8f97c8fe403af9a9dd6e0bb35ff1dd3ad2...1d46d8b7ce6220311198013f0172ff3af9e66dab
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list