diff options
Diffstat (limited to 'libvo/vo_yuv4mpeg.c')
-rw-r--r-- | libvo/vo_yuv4mpeg.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/libvo/vo_yuv4mpeg.c b/libvo/vo_yuv4mpeg.c index f4cbfb1639..0cc7f9a62c 100644 --- a/libvo/vo_yuv4mpeg.c +++ b/libvo/vo_yuv4mpeg.c @@ -56,7 +56,9 @@ #include "fastmemcpy.h" #include "libswscale/swscale.h" +#ifdef CONFIG_LIBSWSCALE_INTERNALS #include "libswscale/rgb2rgb.h" +#endif #include "libmpcodecs/vf_scale.h" #include "libavutil/rational.h" @@ -122,42 +124,44 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, { if (height % 4) { - mp_msg(MSGT_VO,MSGL_FATAL, - MSGTR_VO_YUV4MPEG_InterlacedHeightDivisibleBy4); + mp_tmsg(MSGT_VO,MSGL_FATAL, + "Interlaced mode requires image height to be divisible by 4."); return -1; } rgb_line_buffer = malloc(image_width * 3); if (!rgb_line_buffer) { - mp_msg(MSGT_VO,MSGL_FATAL, - MSGTR_VO_YUV4MPEG_InterlacedLineBufAllocFail); + mp_tmsg(MSGT_VO,MSGL_FATAL, + "Unable to allocate line buffer for interlaced mode."); return -1; } if (using_format == IMGFMT_YV12) - mp_msg(MSGT_VO,MSGL_WARN, - MSGTR_VO_YUV4MPEG_InterlacedInputNotRGB); + mp_tmsg(MSGT_VO,MSGL_WARN, + "Input not RGB, can't separate chrominance by fields!"); } if (width % 2) { - mp_msg(MSGT_VO,MSGL_FATAL, - MSGTR_VO_YUV4MPEG_WidthDivisibleBy2); + mp_tmsg(MSGT_VO,MSGL_FATAL, + "Image width must be divisible by 2."); return -1; } +#ifdef CONFIG_LIBSWSCALE_INTERNALS if(using_format != IMGFMT_YV12) { sws_rgb2rgb_init(get_sws_cpuflags()); rgb_buffer = malloc(image_width * image_height * 3); if (!rgb_buffer) { - mp_msg(MSGT_VO,MSGL_FATAL, - MSGTR_VO_YUV4MPEG_NoMemRGBFrameBuf); + mp_tmsg(MSGT_VO,MSGL_FATAL, + "Not enough memory to allocate RGB framebuffer."); return -1; } } +#endif write_bytes = image_width * image_height * 3 / 2; image = malloc(write_bytes); @@ -165,8 +169,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, yuv_out = fopen(yuv_filename, "wb"); if (!yuv_out || image == 0) { - mp_msg(MSGT_VO,MSGL_FATAL, - MSGTR_VO_YUV4MPEG_OutFileOpenError, + mp_tmsg(MSGT_VO,MSGL_FATAL, + "Can't get memory or file handle to write \"%s\"!", yuv_filename); return -1; } @@ -228,6 +232,7 @@ static void draw_osd(void) vo_draw_text(image_width, image_height, draw_alpha); } +#ifdef CONFIG_LIBSWSCALE_INTERNALS static void deinterleave_fields(uint8_t *ptr, const int stride, const int img_height) { @@ -258,12 +263,13 @@ static void deinterleave_fields(uint8_t *ptr, const int stride, } free(line_state); } +#endif static void vo_y4m_write(const void *ptr, const size_t num_bytes) { if (fwrite(ptr, 1, num_bytes, yuv_out) != num_bytes) - mp_msg(MSGT_VO,MSGL_ERR, - MSGTR_VO_YUV4MPEG_OutFileWriteError); + mp_tmsg(MSGT_VO,MSGL_ERR, + "Error writing image to output!"); } static int write_last_frame(void) @@ -318,14 +324,15 @@ static int write_last_frame(void) static void flip_page (void) { - uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower; - int rgb_stride, uv_stride, field_height; - unsigned int i, low_ofs; - fprintf(yuv_out, "FRAME\n"); +#ifdef CONFIG_LIBSWSCALE_INTERNALS if (using_format != IMGFMT_YV12) { + uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower; + int rgb_stride, uv_stride, field_height; + unsigned int i, low_ofs; + rgb_stride = image_width * 3; uv_stride = image_width / 2; @@ -374,6 +381,7 @@ static void flip_page (void) image_width, image_height, image_width, uv_stride, rgb_stride); } +#endif /* Write progressive frame */ vo_y4m_write(image, write_bytes); @@ -458,9 +466,11 @@ static int query_format(uint32_t format) { case IMGFMT_YV12: return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; +#ifdef CONFIG_LIBSWSCALE_INTERNALS case IMGFMT_BGR|24: case IMGFMT_RGB|24: return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; +#endif } } else @@ -470,9 +480,11 @@ static int query_format(uint32_t format) { case IMGFMT_YV12: return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; +#ifdef CONFIG_LIBSWSCALE_INTERNALS case IMGFMT_BGR|24: case IMGFMT_RGB|24: return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; +#endif } } return 0; @@ -524,7 +536,7 @@ static int preinit(const char *arg) il_bf = 0; yuv_filename = strdup("stream.yuv"); if (subopt_parse(arg, subopts) != 0) { - mp_msg(MSGT_VO, MSGL_FATAL, MSGTR_VO_YUV4MPEG_UnknownSubDev, arg); + mp_tmsg(MSGT_VO, MSGL_FATAL, "Unknown subdevice: %s", arg); return -1; } @@ -538,22 +550,22 @@ static int preinit(const char *arg) switch (config_interlace) { case Y4M_ILACE_TOP_FIRST: - mp_msg(MSGT_VO,MSGL_STATUS, - MSGTR_VO_YUV4MPEG_InterlacedTFFMode); + mp_tmsg(MSGT_VO,MSGL_STATUS, + "Using interlaced output mode, top-field first."); break; case Y4M_ILACE_BOTTOM_FIRST: - mp_msg(MSGT_VO,MSGL_STATUS, - MSGTR_VO_YUV4MPEG_InterlacedBFFMode); + mp_tmsg(MSGT_VO,MSGL_STATUS, + "Using interlaced output mode, bottom-field first."); break; default: - mp_msg(MSGT_VO,MSGL_STATUS, - MSGTR_VO_YUV4MPEG_ProgressiveMode); + mp_tmsg(MSGT_VO,MSGL_STATUS, + "Using (default) progressive frame mode."); break; } return 0; } -static int control(uint32_t request, void *data, ...) +static int control(uint32_t request, void *data) { switch (request) { case VOCTRL_QUERY_FORMAT: |