diff options
author | Reinhard Nißl <rnissl@gmx.de> | 2008-05-12 15:56:10 +0200 |
---|---|---|
committer | Reinhard Nißl <rnissl@gmx.de> | 2008-05-12 15:56:10 +0200 |
commit | bc8854c662e868e0b8f68ba9eecce6515241b967 (patch) | |
tree | e07fb7da35a06a74ae3e7cfd8a2470fc5c98a756 /src | |
parent | 3d3343de9ffdae49eb24367c3df8b81e5f4eea55 (diff) | |
download | xine-lib-bc8854c662e868e0b8f68ba9eecce6515241b967.tar.gz xine-lib-bc8854c662e868e0b8f68ba9eecce6515241b967.tar.bz2 |
Provide xine_get_current_frame_data which passes more data via a structure.
The new structure xine_current_frame_data_t additionally contains cropping
and interlacing information, which both are required for proper conversion
of the image. The existing functions have been adopted to use the code of
the new function. The changeset should be ABI compatible.
Diffstat (limited to 'src')
-rw-r--r-- | src/xine-engine/xine.c | 139 |
1 files changed, 94 insertions, 45 deletions
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 8c4ce8e4e..558aa996e 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -1933,9 +1933,9 @@ int xine_get_pos_length (xine_stream_t *stream, int *pos_stream, return 1; } -static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *height, - int *ratio_code, int *format, - uint8_t **img, int *size, int alloc_img) { +static int _x_get_current_frame_data (xine_stream_t *stream, + xine_current_frame_data_t *data, + int flags, int img_size_unknown) { vo_frame_t *frame; size_t required_size; @@ -1944,42 +1944,49 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he frame = stream->video_out->get_last_frame (stream->video_out); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); - if (!frame) + if (!frame) { + data->img_size = 0; return 0; + } - *width = frame->width; - *height = frame->height; + data->width = frame->width; + data->height = frame->height; + data->crop_left = frame->crop_left; + data->crop_right = frame->crop_right; + data->crop_top = frame->crop_top; + data->crop_bottom = frame->crop_bottom; - *ratio_code = 10000.0 * frame->ratio; + data->ratio_code = 10000.0 * frame->ratio; /* make ratio_code backward compatible */ #define RATIO_LIKE(a, b) ((b) - 1 <= (a) && (a) <= 1 + (b)) - if (RATIO_LIKE(*ratio_code, 10000)) - *ratio_code = XINE_VO_ASPECT_SQUARE; - else if (RATIO_LIKE(*ratio_code, 13333)) - *ratio_code = XINE_VO_ASPECT_4_3; - else if (RATIO_LIKE(*ratio_code, 17778)) - *ratio_code = XINE_VO_ASPECT_ANAMORPHIC; - else if (RATIO_LIKE(*ratio_code, 21100)) - *ratio_code = XINE_VO_ASPECT_DVB; + if (RATIO_LIKE(data->ratio_code, 10000)) + data->ratio_code = XINE_VO_ASPECT_SQUARE; + else if (RATIO_LIKE(data->ratio_code, 13333)) + data->ratio_code = XINE_VO_ASPECT_4_3; + else if (RATIO_LIKE(data->ratio_code, 17778)) + data->ratio_code = XINE_VO_ASPECT_ANAMORPHIC; + else if (RATIO_LIKE(data->ratio_code, 21100)) + data->ratio_code = XINE_VO_ASPECT_DVB; - *format = frame->format; + data->format = frame->format; + data->interlaced = frame->progressive_frame ? 0 : (2 - frame->top_field_first); - switch (*format) { + switch (frame->format) { case XINE_IMGFMT_YV12: - required_size = *width * *height - + ((*width + 1) / 2) * ((*height + 1) / 2) - + ((*width + 1) / 2) * ((*height + 1) / 2); + required_size = frame->width * frame->height + + ((frame->width + 1) / 2) * ((frame->height + 1) / 2) + + ((frame->width + 1) / 2) * ((frame->height + 1) / 2); break; case XINE_IMGFMT_YUY2: - required_size = *width * *height - + ((*width + 1) / 2) * *height - + ((*width + 1) / 2) * *height; + required_size = frame->width * frame->height + + ((frame->width + 1) / 2) * frame->height + + ((frame->width + 1) / 2) * frame->height; break; default: - if (*img || alloc_img) { + if (data->img || (flags & XINE_FRAME_DATA_ALLOCATE_IMG)) { xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "xine: error, snapshot function not implemented for format 0x%x\n", frame->format); _x_abort (); @@ -1988,38 +1995,36 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he required_size = 0; } - if (alloc_img) { - /* return size if requested */ - if (size) - *size = required_size; + if (flags & XINE_FRAME_DATA_ALLOCATE_IMG) { + /* return allocated buffer size */ + data->img_size = required_size; /* allocate img or fail */ - if (!(*img = calloc(1, required_size))) + if (!(data->img = calloc(1, required_size))) return 0; } else { /* fail if supplied buffer is to small */ - if (*img && size && *size < required_size) { - *size = required_size; + if (data->img && !img_size_unknown && data->img_size < required_size) { + data->img_size = required_size; return 0; } - /* return size if requested */ - if (size) - *size = required_size; + /* return used buffer size */ + data->img_size = required_size; } - if (*img) { + if (data->img) { switch (frame->format) { case XINE_IMGFMT_YV12: yv12_to_yv12( /* Y */ frame->base[0], frame->pitches[0], - *img, frame->width, + data->img, frame->width, /* U */ frame->base[1], frame->pitches[1], - *img+frame->width*frame->height, frame->width/2, + data->img+frame->width*frame->height, frame->width/2, /* V */ frame->base[2], frame->pitches[2], - *img+frame->width*frame->height+frame->width*frame->height/4, frame->width/2, + data->img+frame->width*frame->height+frame->width*frame->height/4, frame->width/2, /* width x height */ frame->width, frame->height); break; @@ -2029,7 +2034,7 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he /* src */ frame->base[0], frame->pitches[0], /* dst */ - *img, frame->width*2, + data->img, frame->width*2, /* width x height */ frame->width, frame->height); break; @@ -2043,23 +2048,67 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he return 1; } +int xine_get_current_frame_data (xine_stream_t *stream, + xine_current_frame_data_t *data, + int flags) { + + return _x_get_current_frame_data(stream, data, flags, 0); +} + int xine_get_current_frame_alloc (xine_stream_t *stream, int *width, int *height, int *ratio_code, int *format, - uint8_t **img, int *size) { - uint8_t *no_img = NULL; - return _x_get_current_frame_impl(stream, width, height, ratio_code, format, img ? img : &no_img, size, img != NULL); + uint8_t **img, int *img_size) { + + int result; + xine_current_frame_data_t data; + + memset(&data, 0, sizeof (data)); + + result = _x_get_current_frame_data(stream, &data, img ? XINE_FRAME_DATA_ALLOCATE_IMG : 0, 0); + if (width) *width = data.width; + if (height) *height = data.height; + if (ratio_code) *ratio_code = data.ratio_code; + if (format) *format = data.format; + if (img_size) *img_size = data.img_size; + if (img) *img = data.img; + return result; } int xine_get_current_frame_s (xine_stream_t *stream, int *width, int *height, int *ratio_code, int *format, - uint8_t *img, int *size) { - return (!img || size) && _x_get_current_frame_impl(stream, width, height, ratio_code, format, &img, size, 0); + uint8_t *img, int *img_size) { + int result; + xine_current_frame_data_t data; + + memset(&data, 0, sizeof (data)); + data.img = img; + if (img_size) + data.img_size = *img_size; + + result = _x_get_current_frame_data(stream, &data, 0, 0); + if (width) *width = data.width; + if (height) *height = data.height; + if (ratio_code) *ratio_code = data.ratio_code; + if (format) *format = data.format; + if (img_size) *img_size = data.img_size; + return result; } int xine_get_current_frame (xine_stream_t *stream, int *width, int *height, int *ratio_code, int *format, uint8_t *img) { - return _x_get_current_frame_impl(stream, width, height, ratio_code, format, &img, NULL, 0); + int result; + xine_current_frame_data_t data; + + memset(&data, 0, sizeof (data)); + data.img = img; + + result = _x_get_current_frame_data(stream, &data, 0, 1); + if (width) *width = data.width; + if (height) *height = data.height; + if (ratio_code) *ratio_code = data.ratio_code; + if (format) *format = data.format; + return result; } int xine_get_video_frame (xine_stream_t *stream, |