Created
October 9, 2014 03:44
-
-
Save whatvn/b20234a20703416b79d5 to your computer and use it in GitHub Desktop.
scale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static AVFrame* scale_encode_write_frame(AVFrame *frame, int src_w, int src_h, | |
int dst_w, int dst_h) { | |
int ret = 0; | |
AVFrame *scale_frame; | |
frame = av_frame_alloc(); | |
if (!frame) { | |
av_log(NULL, AV_LOG_DEBUG, "Cannot get allocate scale frame\n"); | |
return frame; | |
} | |
SwsContext *scale_context = NULL; | |
scale_context = sws_getContext(src_w, src_h, | |
ifmt_ctx->video_codec->pix_fmts, | |
dst_w, dst_h, | |
ifmt_ctx->video_codec->pix_fmts, SWS_BILINEAR, NULL, NULL, NULL); | |
if (!scale_context) { | |
av_log(NULL, AV_LOG_DEBUG, "Cannot get scaling context\n"); | |
av_frame_free(&scale_frame); | |
return frame; | |
} | |
ret = sws_scale(scale_context, (const uint8_t * const*) frame->data, | |
(const int) frame->linesize, 0, src_h, | |
scale_frame->data, frame->linesize); | |
sws_freeContext(scale_context); | |
if (ret < 0) { | |
av_frame_free(&scale_frame); | |
return frame; | |
} else { | |
av_frame_free(&frame); | |
return scale_frame; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment