comparison mpeg12.c @ 9904:efd0c5014ac7 libavcodec

simplify slice_end, return size of output frame
author bcoudurier
date Wed, 01 Jul 2009 17:29:52 +0000
parents 5d0f71ba8648
children a37ffec2074c
comparison
equal deleted inserted replaced
9903:305536ce781f 9904:efd0c5014ac7
1933 return 0; //not reached 1933 return 0; //not reached
1934 } 1934 }
1935 1935
1936 /** 1936 /**
1937 * Handles slice ends. 1937 * Handles slice ends.
1938 * @return 1 if it seems to be the last slice 1938 * @return sizeof(AVFrame) if a frame is output, 0 otherwise
1939 */ 1939 */
1940 static int slice_end(AVCodecContext *avctx, AVFrame *pict) 1940 static int slice_end(AVCodecContext *avctx, AVFrame *pict)
1941 { 1941 {
1942 Mpeg1Context *s1 = avctx->priv_data; 1942 Mpeg1Context *s1 = avctx->priv_data;
1943 MpegEncContext *s = &s1->mpeg_enc_ctx; 1943 MpegEncContext *s = &s1->mpeg_enc_ctx;
1964 MPV_frame_end(s); 1964 MPV_frame_end(s);
1965 1965
1966 if (s->pict_type == FF_B_TYPE || s->low_delay) { 1966 if (s->pict_type == FF_B_TYPE || s->low_delay) {
1967 *pict= *(AVFrame*)s->current_picture_ptr; 1967 *pict= *(AVFrame*)s->current_picture_ptr;
1968 ff_print_debug_info(s, pict); 1968 ff_print_debug_info(s, pict);
1969 return sizeof(*pict);
1969 } else { 1970 } else {
1970 s->picture_number++; 1971 s->picture_number++;
1971 /* latency of 1 frame for I- and P-frames */ 1972 /* latency of 1 frame for I- and P-frames */
1972 /* XXX: use another variable than picture_number */ 1973 /* XXX: use another variable than picture_number */
1973 if (s->last_picture_ptr != NULL) { 1974 if (s->last_picture_ptr != NULL) {
1974 *pict= *(AVFrame*)s->last_picture_ptr; 1975 *pict= *(AVFrame*)s->last_picture_ptr;
1975 ff_print_debug_info(s, pict); 1976 ff_print_debug_info(s, pict);
1976 } 1977 return sizeof(*pict);
1977 } 1978 }
1978 1979 }
1979 return 1; 1980 }
1980 } else { 1981 return 0;
1981 return 0;
1982 }
1983 } 1982 }
1984 1983
1985 static int mpeg1_decode_sequence(AVCodecContext *avctx, 1984 static int mpeg1_decode_sequence(AVCodecContext *avctx,
1986 const uint8_t *buf, int buf_size) 1985 const uint8_t *buf, int buf_size)
1987 { 1986 {
2315 } 2314 }
2316 2315
2317 if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) 2316 if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
2318 ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count); 2317 ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count);
2319 2318
2320 if (slice_end(avctx, picture)) { 2319 *data_size = slice_end(avctx, picture);
2321 if(s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice
2322 *data_size = sizeof(AVPicture);
2323 }
2324 } 2320 }
2325 s2->pict_type= 0; 2321 s2->pict_type= 0;
2326 return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index); 2322 return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index);
2327 } 2323 }
2328 2324