comparison libmpcodecs/vd_ffmpeg.c @ 34021:fbb87f092560

Get rid of usage of deprecated palctrl which no longer works anyway. Set up side data instead. Note that for lavf demuxer we will use the merged side data anyway, this is only for our own, e.g. AVI demuxer. Fixes bug #1976.
author reimar
date Sat, 17 Sep 2011 16:48:40 +0000
parents a5f1aaf21790
children fab5ae1132e7
comparison
equal deleted inserted replaced
34020:0af747024f32 34021:fbb87f092560
68 double qp_sum; 68 double qp_sum;
69 double inv_qp_sum; 69 double inv_qp_sum;
70 int ip_count; 70 int ip_count;
71 int b_count; 71 int b_count;
72 AVRational last_sample_aspect_ratio; 72 AVRational last_sample_aspect_ratio;
73 int palette_sent;
73 } vd_ffmpeg_ctx; 74 } vd_ffmpeg_ctx;
74 75
75 #include "m_option.h" 76 #include "m_option.h"
76 77
77 static int get_buffer(AVCodecContext *avctx, AVFrame *pic); 78 static int get_buffer(AVCodecContext *avctx, AVFrame *pic);
362 avctx->extradata_size = sh->bih->biSize-sizeof(*sh->bih); 363 avctx->extradata_size = sh->bih->biSize-sizeof(*sh->bih);
363 avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 364 avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
364 memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size); 365 memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size);
365 break; 366 break;
366 } 367 }
367 /* Pass palette to codec */
368 if (sh->bih && (sh->bih->biBitCount <= 8)) {
369 avctx->palctrl = av_mallocz(sizeof(AVPaletteControl));
370 avctx->palctrl->palette_changed = 1;
371 if (sh->bih->biSize-sizeof(*sh->bih))
372 /* Palette size in biSize */
373 memcpy(avctx->palctrl->palette, sh->bih+1,
374 FFMIN(sh->bih->biSize-sizeof(*sh->bih), AVPALETTE_SIZE));
375 else
376 /* Palette size in biClrUsed */
377 memcpy(avctx->palctrl->palette, sh->bih+1,
378 FFMIN(sh->bih->biClrUsed * 4, AVPALETTE_SIZE));
379 }
380 368
381 if(sh->bih) 369 if(sh->bih)
382 avctx->bits_per_coded_sample= sh->bih->biBitCount; 370 avctx->bits_per_coded_sample= sh->bih->biBitCount;
383 371
384 avctx->thread_count = lavc_param_threads; 372 avctx->thread_count = lavc_param_threads;
789 av_init_packet(&pkt); 777 av_init_packet(&pkt);
790 pkt.data = data; 778 pkt.data = data;
791 pkt.size = len; 779 pkt.size = len;
792 // HACK: make PNGs decode normally instead of as CorePNG delta frames 780 // HACK: make PNGs decode normally instead of as CorePNG delta frames
793 pkt.flags = AV_PKT_FLAG_KEY; 781 pkt.flags = AV_PKT_FLAG_KEY;
782 if (!ctx->palette_sent && sh->bih && sh->bih->biBitCount <= 8) {
783 /* Pass palette to codec */
784 uint8_t *pal = av_packet_new_side_data(&pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
785 unsigned palsize = sh->bih->biSize - sizeof(*sh->bih);
786 if (palsize == 0) {
787 /* Palette size in biClrUsed */
788 palsize = sh->bih->biClrUsed * 4;
789 }
790 memcpy(pal, sh->bih+1, FFMIN(palsize, AVPALETTE_SIZE));
791 ctx->palette_sent = 1;
792 }
794 ret = avcodec_decode_video2(avctx, pic, &got_picture, &pkt); 793 ret = avcodec_decode_video2(avctx, pic, &got_picture, &pkt);
794 pkt.data = NULL;
795 pkt.size = 0;
796 av_destruct_packet(&pkt);
795 797
796 dr1= ctx->do_dr1; 798 dr1= ctx->do_dr1;
797 if(ret<0) mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error while decoding frame!\n"); 799 if(ret<0) mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error while decoding frame!\n");
798 //printf("repeat: %d\n", pic->repeat_pict); 800 //printf("repeat: %d\n", pic->repeat_pict);
799 //-- vstats generation 801 //-- vstats generation