Ticket #244: xpra-fix-new-libav.patch
File xpra-fix-new-libav.patch, 2.1 KB (added by , 8 years ago) |
---|
-
xpra/x264/
old new 55 55 // Decoding 56 56 AVCodec *codec; 57 57 AVCodecContext *codec_ctx; 58 AVFrame *frame; 58 59 struct SwsContext *yuv2rgb; 59 60 60 61 // Encoding … … 251 252 fprintf(stderr, "could not open codec\n"); 252 253 return 1; 253 254 } 255 ctx->frame = avcodec_alloc_frame(); 256 if (!ctx->frame) { 257 fprintf(stderr, "could not allocate an AVFrame for decoding\n"); 258 return 1; 259 } 254 260 return 0; 255 261 } 256 262 struct x264lib_ctx *init_decoder(int width, int height, int csc_fmt) … … 275 281 sws_freeContext(ctx->yuv2rgb); 276 282 ctx->yuv2rgb = NULL; 277 283 } 284 avcodec_free_frame(&ctx->frame); 278 285 } 279 286 void clean_decoder(struct x264lib_ctx *ctx) 280 287 { … … 390 397 int got_picture; 391 398 int len; 392 399 int i; 393 AVFrame picture;400 AVFrame *picture = ctx->frame; 394 401 AVPacket avpkt; 395 402 396 403 av_init_packet(&avpkt); … … 398 405 if (!ctx->codec_ctx || !ctx->codec) 399 406 return 1; 400 407 401 avcodec_get_frame_defaults( &picture);408 avcodec_get_frame_defaults(picture); 402 409 403 410 avpkt.data = in; 404 411 avpkt.size = size; 405 412 406 len = avcodec_decode_video2(ctx->codec_ctx, &picture, &got_picture, &avpkt);413 len = avcodec_decode_video2(ctx->codec_ctx, picture, &got_picture, &avpkt); 407 414 if (len < 0) { 408 415 fprintf(stderr, "Error while decoding frame\n"); 409 416 memset(out, 0, sizeof(*out)); … … 411 418 } 412 419 413 420 for (i = 0; i < 3; i++) { 414 (*out)[i] = picture .data[i];415 *outsize += ctx->height * picture .linesize[i];416 (*outstride)[i] = picture .linesize[i];421 (*out)[i] = picture->data[i]; 422 *outsize += ctx->height * picture->linesize[i]; 423 (*outstride)[i] = picture->linesize[i]; 417 424 } 418 425 419 426 if (*outsize == 0) { 420 fprintf(stderr, "Decoded image, size %d %d %d, ptr %p %p %p\n", (*outstride)[0] * ctx->height, (*outstride)[1]*ctx->height, (*outstride)[2]*ctx->height, picture .data[0], picture.data[1], picture.data[2]);427 fprintf(stderr, "Decoded image, size %d %d %d, ptr %p %p %p\n", (*outstride)[0] * ctx->height, (*outstride)[1]*ctx->height, (*outstride)[2]*ctx->height, picture->data[0], picture->data[1], picture->data[2]); 421 428 return 3; 422 429 } 423 430