Browse Source

lib: media: Allow thumbnails to be cropped

pull/91/head
Hugo Beauzée-Luyssen 7 years ago
parent
commit
6c8f81953e
  1. 4
      include/vlc/libvlc_media.h
  2. 10
      lib/media.c
  3. 5
      lib/picture.c
  4. 4
      lib/picture_internal.h

4
include/vlc/libvlc_media.h

@ -847,7 +847,7 @@ libvlc_media_thumbnail_request_by_time( libvlc_media_t *md,
libvlc_time_t time,
libvlc_thumbnailer_seek_speed_t speed,
unsigned int width, unsigned int height,
libvlc_picture_type_t picture_type,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout );
/**
@ -877,7 +877,7 @@ libvlc_media_thumbnail_request_by_pos( libvlc_media_t *md,
float pos,
libvlc_thumbnailer_seek_speed_t speed,
unsigned int width, unsigned int height,
libvlc_picture_type_t picture_type,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout );
/**

10
lib/media.c

@ -1096,6 +1096,7 @@ struct libvlc_media_thumbnail_request_t
libvlc_media_t *md;
unsigned int width;
unsigned int height;
bool crop;
libvlc_picture_type_t type;
vlc_thumbnailer_request_t* req;
};
@ -1109,7 +1110,8 @@ static void media_on_thumbnail_ready( void* data, picture_t* thumbnail )
libvlc_picture_t* pic = NULL;
if ( thumbnail != NULL )
pic = libvlc_picture_new( VLC_OBJECT(p_media->p_libvlc_instance->p_libvlc_int),
thumbnail, req->type, req->width, req->height );
thumbnail, req->type, req->width, req->height,
req->crop );
event.u.media_thumbnail_generated.p_thumbnail = pic;
libvlc_event_send( &p_media->event_manager, &event );
if ( pic != NULL )
@ -1122,7 +1124,7 @@ libvlc_media_thumbnail_request_t*
libvlc_media_thumbnail_request_by_time( libvlc_media_t *md, libvlc_time_t time,
libvlc_thumbnailer_seek_speed_t speed,
unsigned int width, unsigned int height,
libvlc_picture_type_t picture_type,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout )
{
assert( md );
@ -1137,6 +1139,7 @@ libvlc_media_thumbnail_request_by_time( libvlc_media_t *md, libvlc_time_t time,
req->width = width;
req->height = height;
req->type = picture_type;
req->crop = crop;
libvlc_media_retain( md );
req->req = vlc_thumbnailer_RequestByTime( p_priv->p_thumbnailer,
VLC_TICK_FROM_MS( time ),
@ -1158,7 +1161,7 @@ libvlc_media_thumbnail_request_t*
libvlc_media_thumbnail_request_by_pos( libvlc_media_t *md, float pos,
libvlc_thumbnailer_seek_speed_t speed,
unsigned int width, unsigned int height,
libvlc_picture_type_t picture_type,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout )
{
assert( md );
@ -1172,6 +1175,7 @@ libvlc_media_thumbnail_request_by_pos( libvlc_media_t *md, float pos,
req->md = md;
req->width = width;
req->height = height;
req->crop = crop;
req->type = picture_type;
libvlc_media_retain( md );
req->req = vlc_thumbnailer_RequestByPos( priv->p_thumbnailer, pos,

5
lib/picture.c

@ -45,7 +45,8 @@ struct libvlc_picture_t
libvlc_picture_t* libvlc_picture_new( vlc_object_t* p_obj, picture_t* input,
libvlc_picture_type_t type,
unsigned int width, unsigned int height )
unsigned int width, unsigned int height,
bool crop )
{
libvlc_picture_t *pic = malloc( sizeof( *pic ) );
if ( unlikely( pic == NULL ) )
@ -69,7 +70,7 @@ libvlc_picture_t* libvlc_picture_new( vlc_object_t* p_obj, picture_t* input,
vlc_assert_unreachable();
}
if ( picture_Export( p_obj, &pic->converted, &pic->fmt,
input, format, width, height, false ) != VLC_SUCCESS )
input, format, width, height, crop ) != VLC_SUCCESS )
{
free( pic );
return NULL;

4
lib/picture_internal.h

@ -32,6 +32,7 @@
* \param i_type Desired converted picture type
* \param i_width Converted picture width
* \param i_height Converted picture height
* \param b_crop Should the picture be cropped to preserve aspect ratio
* \return An opaque libvlc_picture_t
*
* The picture refcount is left untouched by this function, but is converted to
@ -40,6 +41,7 @@
*/
libvlc_picture_t* libvlc_picture_new( vlc_object_t* p_obj, picture_t* p_pic,
libvlc_picture_type_t i_format,
unsigned int i_width, unsigned int i_height );
unsigned int i_width, unsigned int i_height,
bool b_crop );
#endif /* PICTURE_INTERNAL_H */

Loading…
Cancel
Save