Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int resizeFrame(int colorspace, int width, int height, AVFrame *frame) {
- AVFrame *newFrame = NULL;
- newFrame = avcodec_alloc_frame();
- if(frame == NULL)
- return -1;
- int numBytes = avpicture_get_size(colorspace, width, height);
- uint8_t *buffer = NULL;
- buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
- avpicture_fill((AVPicture *)newFrame, buffer, colorspace, width, height);
- newFrame->width = width;
- newFrame->height = height;
- newFrame->format = colorspace;
- struct SwsContext *resizeContext = NULL;
- resizeContext = sws_getContext (
- frame->width,
- frame->height,
- frame->format,
- newFrame->width,
- newFrame->height,
- newFrame->format,
- SWS_SPLINE,
- NULL,
- NULL,
- NULL
- );
- int linesWritten = sws_scale (
- resizeContext,
- (uint8_t const * const *)frame->data,
- frame->linesize,
- 0,
- newFrame->height,
- newFrame->data,
- newFrame->linesize
- );
- printf("Lines Written: %i\n", linesWritten);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement