[FFmpeg-devel] [PATCH] API changes in ffmpeg.c
Thilo Borgmann
thilo.borgmann
Fri Apr 10 14:45:48 CEST 2009
A new thread for the API changes in ffmpeg.c, cut off from the original
thread:
Stefano Sabatini schrieb:
> On date Wednesday 2009-04-08 16:09:01 +0200, Thilo Borgmann encoded:
> [...]
>
>> diff --git a/ffmpeg.c b/ffmpeg.c
>> index cb15120..4944811 100644
>> --- a/ffmpeg.c
>> +++ b/ffmpeg.c
>> @@ -1174,8 +1174,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
>> {
>> AVFormatContext *os;
>> AVOutputStream *ost;
>> - uint8_t *ptr;
>> - int len, ret, i;
>> + int ret, i;
>> uint8_t *data_buf;
>> int data_size, got_picture;
>> AVFrame picture;
>> @@ -1184,29 +1183,32 @@ static int output_packet(AVInputStream *ist, int ist_index,
>> static short *samples= NULL;
>> AVSubtitle subtitle, *subtitle_to_free;
>> int got_subtitle;
>> + AVPacket avpkt;
>> +
>> + av_init_packet(&avpkt);
>>
>> if(ist->next_pts == AV_NOPTS_VALUE)
>> ist->next_pts= ist->pts;
>>
>> if (pkt == NULL) {
>> /* EOF handling */
>> - ptr = NULL;
>> - len = 0;
>> + avpkt.data = NULL;
>> + avpkt.size = 0;
>> goto handle_eof;
>> }
>>
>> if(pkt->dts != AV_NOPTS_VALUE)
>> ist->next_pts = ist->pts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
>>
>> - len = pkt->size;
>> - ptr = pkt->data;
>> + avpkt.size = pkt->size;
>> + avpkt.data = pkt->data;
>>
>> //while we have more to decode or while the decoder did output something on EOF
>> - while (len > 0 || (!pkt && ist->next_pts != ist->pts)) {
>> + while (avpkt.size > 0 || (!pkt && ist->next_pts != ist->pts)) {
>> handle_eof:
>> ist->pts= ist->next_pts;
>>
>> - if(len && len != pkt->size && verbose>0)
>> + if(avpkt.size && avpkt.size != pkt->size && verbose>0)
>> fprintf(stderr, "Multiple frames in a packet from stream %d\n", pkt->stream_index);
>>
>> /* decode the packet if needed */
>> @@ -1224,12 +1226,12 @@ static int output_packet(AVInputStream *ist, int ist_index,
>> data_size= samples_size;
>> /* XXX: could avoid copy if PCM 16 bits with same
>> endianness as CPU */
>> - ret = avcodec_decode_audio2(ist->st->codec, samples, &data_size,
>> - ptr, len);
>> + ret = avcodec_decode_audio3(ist->st->codec, samples, &data_size,
>> + pkt);
>> if (ret < 0)
>> goto fail_decode;
>> - ptr += ret;
>> - len -= ret;
>> + avpkt.data += ret;
>> + avpkt.size -= ret;
>> /* Some bug in mpeg audio decoder gives */
>> /* data_size < 0, it seems they are overflows */
>> if (data_size <= 0) {
>> @@ -1245,8 +1247,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
>> /* XXX: allocate picture correctly */
>> avcodec_get_frame_defaults(&picture);
>>
>> - ret = avcodec_decode_video(ist->st->codec,
>> - &picture, &got_picture, ptr, len);
>> + ret = avcodec_decode_video2(ist->st->codec,
>> + &picture, &got_picture, pkt);
>>
>
> Crash here.
>
This is revision 1 which fixes the crash during make test.
TB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tb.APICallsInFFmpeg.rev1.patch
Type: text/x-patch
Size: 4591 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090410/f6cc9367/attachment.bin>
More information about the ffmpeg-devel
mailing list