static void uninit(void) { int j; mp_msg(MSGT_VO, MSGL_V, "zr: uninit called\n"); for (j = 0; j < zr_count; j++) { jpeg_enc_uninit(zr_info[j].j); uninit_zoran(&zr_info[j]); } }
/** * \param vf pointer to the vf instance structure */ static void uninit(vf_instance_t *vf) { struct vf_priv_s *priv = vf->priv; VERBOSE("uninit() called\n"); if (priv->j) jpeg_enc_uninit(priv->j); free(priv); }
/** * \param vf video filter instance pointer * \param width image source width in pixels * \param height image source height in pixels * \param d_width width of requested window, just a hint * \param d_height height of requested window, just a hint * \param flags vf filter flags * \param outfmt * * \returns returns 0 on error * * This routine will make the necessary hardware-related decisions for * the ZRMJPEG filter, do the initialization of the MJPEG encoder, and * then select one of the ZRJMJPEGIT or ZRMJPEGNI filters and then * arrange to dispatch to the config() entry pointer for the one * selected. */ static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ struct vf_priv_s *priv = vf->priv; float aspect_decision; int stretchx, stretchy, err = 0, maxstretchx = 4; priv->fields = 1; VERBOSE("config() called\n"); if (priv->j) { VERBOSE("re-configuring, resetting JPEG encoder\n"); jpeg_enc_uninit(priv->j); priv->j = NULL; } aspect_decision = ((float)d_width/(float)d_height)/ ((float)width/(float)height); if (aspect_decision > 1.8 && aspect_decision < 2.2) { VERBOSE("should correct aspect by stretching x times 2, %d %d\n", 2*width, priv->maxwidth); if (2*width <= priv->maxwidth) { d_width = 2*width; d_height = height; maxstretchx = 2; } else { WARNING("unable to correct aspect by stretching, because resulting X will be too large, aspect correction by decimating y not yet implemented\n"); d_width = width; d_height = height; } /* prestretch movie */ } else { /* uncorrecting output for now */ d_width = width; d_height = height; } /* make the scaling decision * we are capable of stretching the image in the horizontal * direction by factors 1, 2 and 4 * we can stretch the image in the vertical direction by a * factor of 1 and 2 AND we must decide about interlacing */ if (d_width > priv->maxwidth/2 || height > priv->maxheight/2 || maxstretchx == 1) { stretchx = 1; stretchy = 1; priv->fields = 2; if (priv->vdec == 2) { priv->fields = 1; } else if (priv->vdec == 4) { priv->fields = 1; stretchy = 2; } if (priv->hdec > maxstretchx) { if (priv->fd) { WARNING("horizontal decimation too high, " "changing to %d (use fd to keep" " hdec=%d)\n", maxstretchx, priv->hdec); priv->hdec = maxstretchx; } } stretchx = priv->hdec; } else if (d_width > priv->maxwidth/4 || height > priv->maxheight/4 || maxstretchx == 2) { stretchx = 2; stretchy = 1; priv->fields = 1; if (priv->vdec == 2) { stretchy = 2; } else if (priv->vdec == 4) { if (!priv->fd) { WARNING("vertical decimation too high, " "changing to 2 (use fd to keep " "vdec=4)\n"); priv->vdec = 2; } stretchy = 2; } if (priv->hdec == 2) { stretchx = 4; } else if (priv->hdec == 4) { if (priv->fd) { WARNING("horizontal decimation too high, " "changing to 2 (use fd to keep " "hdec=4)\n"); priv->hdec = 2; } stretchx = 4; } } else { /* output image is maximally stretched */ stretchx = 4; stretchy = 2; priv->fields = 1; if (priv->vdec != 1 && !priv->fd) { WARNING("vertical decimation too high, changing to 1 " "(use fd to keep vdec=%d)\n", priv->vdec); priv->vdec = 1; } if (priv->hdec != 1 && !priv->fd) { WARNING("horizontal decimation too high, changing to 1 (use fd to keep hdec=%d)\n", priv->hdec); priv->hdec = 1; } } VERBOSE("generated JPEG's %dx%s%d%s, stretched to %dx%d\n", width/priv->hdec, (priv->fields == 2) ? "(" : "", height/(priv->vdec*priv->fields), (priv->fields == 2) ? "x2)" : "", (width/priv->hdec)*stretchx, (height/(priv->vdec*priv->fields))* stretchy*priv->fields); if ((width/priv->hdec)*stretchx > priv->maxwidth || (height/(priv->vdec*priv->fields))* stretchy*priv->fields > priv->maxheight) { ERROR("output dimensions too large (%dx%d), max (%dx%d) " "insert crop to fix\n", (width/priv->hdec)*stretchx, (height/(priv->vdec*priv->fields))* stretchy*priv->fields, priv->maxwidth, priv->maxheight); err = 1; } if (width%(16*priv->hdec) != 0) { ERROR("width must be a multiple of 16*hdec (%d), use expand\n", priv->hdec*16); err = 1; } if (height%(8*priv->fields*priv->vdec) != 0) { ERROR("height must be a multiple of 8*fields*vdec (%d)," " use expand\n", priv->vdec*priv->fields*8); err = 1; } if (err) return 0; priv->y_stride = width; priv->c_stride = width/2; priv->j = jpeg_enc_init(width, height/priv->fields, priv->fields*priv->y_stride, priv->fields*priv->c_stride, priv->fields*priv->c_stride, 1, priv->quality, priv->bw); if (!priv->j) return 0; return vf_next_config(vf, width, height, d_width, d_height, flags, (priv->fields == 2) ? IMGFMT_ZRMJPEGIT : IMGFMT_ZRMJPEGNI); }