Mercurial > libavcodec.hg
comparison mpeg12.c @ 1381:f07e17427140 libavcodec
initial XvMC support
author | iive |
---|---|
date | Sat, 26 Jul 2003 01:28:49 +0000 |
parents | b120aed7bf84 |
children | da0b3a50d209 |
comparison
equal
deleted
inserted
replaced
1380:b120aed7bf84 | 1381:f07e17427140 |
---|---|
64 int n); | 64 int n); |
65 static inline int mpeg2_decode_block_intra(MpegEncContext *s, | 65 static inline int mpeg2_decode_block_intra(MpegEncContext *s, |
66 DCTELEM *block, | 66 DCTELEM *block, |
67 int n); | 67 int n); |
68 static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred); | 68 static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred); |
69 | |
70 #ifdef HAVE_XVMC | |
71 extern int XVMC_field_start(MpegEncContext *s, AVCodecContext *avctx); | |
72 extern int XVMC_field_end(MpegEncContext *s); | |
73 #endif | |
69 | 74 |
70 #ifdef CONFIG_ENCODERS | 75 #ifdef CONFIG_ENCODERS |
71 static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL; | 76 static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL; |
72 static uint8_t fcode_tab[MAX_MV*2+1]; | 77 static uint8_t fcode_tab[MAX_MV*2+1]; |
73 | 78 |
1873 if(s->picture_structure == PICT_BOTTOM_FIELD){ | 1878 if(s->picture_structure == PICT_BOTTOM_FIELD){ |
1874 s->current_picture.data[i] += s->current_picture_ptr->linesize[i]; | 1879 s->current_picture.data[i] += s->current_picture_ptr->linesize[i]; |
1875 } | 1880 } |
1876 } | 1881 } |
1877 } | 1882 } |
1878 } | 1883 #ifdef HAVE_XVMC |
1884 // MPV_frame_start will call this function too, | |
1885 // but we need to call it on every field | |
1886 if(s->avctx->xvmc_acceleration) | |
1887 XVMC_field_start(s,avctx); | |
1888 #endif | |
1889 }//fi(s->first_slice) | |
1879 s->first_slice = 0; | 1890 s->first_slice = 0; |
1880 | 1891 |
1881 init_get_bits(&s->gb, *buf, buf_size*8); | 1892 init_get_bits(&s->gb, *buf, buf_size*8); |
1882 | 1893 |
1883 s->qscale = get_qscale(s); | 1894 s->qscale = get_qscale(s); |
2018 MpegEncContext *s = &s1->mpeg_enc_ctx; | 2029 MpegEncContext *s = &s1->mpeg_enc_ctx; |
2019 | 2030 |
2020 if (!s1->mpeg_enc_ctx_allocated) | 2031 if (!s1->mpeg_enc_ctx_allocated) |
2021 return 0; | 2032 return 0; |
2022 | 2033 |
2034 #ifdef HAVE_XVMC | |
2035 if(s->avctx->xvmc_acceleration) | |
2036 XVMC_field_end(s); | |
2037 #endif | |
2023 /* end of slice reached */ | 2038 /* end of slice reached */ |
2024 if (/*s->mb_y<<field_pic == s->mb_height &&*/ !s->first_field) { | 2039 if (/*s->mb_y<<field_pic == s->mb_height &&*/ !s->first_field) { |
2025 /* end of image */ | 2040 /* end of image */ |
2026 | 2041 |
2027 if(s->mpeg2){ | 2042 if(s->mpeg2){ |
2101 MPEG1_FRAME_RATE_BASE, //FIXME store in allready reduced form | 2116 MPEG1_FRAME_RATE_BASE, //FIXME store in allready reduced form |
2102 1<<30 | 2117 1<<30 |
2103 ); | 2118 ); |
2104 avctx->bit_rate = s->bit_rate; | 2119 avctx->bit_rate = s->bit_rate; |
2105 | 2120 |
2121 //get_format() or set_video(width,height,aspect,pix_fmt); | |
2122 //until then pix_fmt may be changed right after codec init | |
2123 if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT ) | |
2124 avctx->idct_algo = FF_IDCT_SIMPLE; | |
2125 | |
2106 if (MPV_common_init(s) < 0) | 2126 if (MPV_common_init(s) < 0) |
2107 return -1; | 2127 return -1; |
2108 s1->mpeg_enc_ctx_allocated = 1; | 2128 s1->mpeg_enc_ctx_allocated = 1; |
2109 } | 2129 } |
2110 | 2130 |
2179 s->width = avctx->width; | 2199 s->width = avctx->width; |
2180 s->height = avctx->height; | 2200 s->height = avctx->height; |
2181 avctx->has_b_frames= 0; //true? | 2201 avctx->has_b_frames= 0; //true? |
2182 s->low_delay= 1; | 2202 s->low_delay= 1; |
2183 s->avctx = avctx; | 2203 s->avctx = avctx; |
2204 | |
2205 //get_format() or set_video(width,height,aspect,pix_fmt); | |
2206 //until then pix_fmt may be changed right after codec init | |
2207 if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT ) | |
2208 avctx->idct_algo = FF_IDCT_SIMPLE; | |
2184 | 2209 |
2185 if (MPV_common_init(s) < 0) | 2210 if (MPV_common_init(s) < 0) |
2186 return -1; | 2211 return -1; |
2187 s1->mpeg_enc_ctx_allocated = 1; | 2212 s1->mpeg_enc_ctx_allocated = 1; |
2188 | 2213 |
2412 mpeg_decode_end, | 2437 mpeg_decode_end, |
2413 mpeg_decode_frame, | 2438 mpeg_decode_frame, |
2414 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, | 2439 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, |
2415 .flush= ff_mpeg_flush, | 2440 .flush= ff_mpeg_flush, |
2416 }; | 2441 }; |
2442 | |
2443 #ifdef HAVE_XVMC | |
2444 static int mpeg_mc_decode_init(AVCodecContext *avctx){ | |
2445 Mpeg1Context *s; | |
2446 | |
2447 if( !(avctx->slice_flags & SLICE_FLAG_CODED_ORDER) ) | |
2448 return -1; | |
2449 if( !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD) ) | |
2450 dprintf("mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n"); | |
2451 | |
2452 mpeg_decode_init(avctx); | |
2453 s = avctx->priv_data; | |
2454 | |
2455 avctx->pix_fmt = PIX_FMT_XVMC_MPEG2_IDCT; | |
2456 avctx->xvmc_acceleration = 1; | |
2457 | |
2458 return 0; | |
2459 } | |
2460 | |
2461 AVCodec mpeg_xvmc_decoder = { | |
2462 "mpegvideo_xvmc", | |
2463 CODEC_TYPE_VIDEO, | |
2464 CODEC_ID_MPEG2VIDEO_XVMC, | |
2465 sizeof(Mpeg1Context), | |
2466 mpeg_mc_decode_init, | |
2467 NULL, | |
2468 mpeg_decode_end, | |
2469 mpeg_decode_frame, | |
2470 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, | |
2471 }; | |
2472 | |
2473 #endif |