Revision 036c1382

View differences:

ffmpeg.c
1299 1299

  
1300 1300
    //while we have more to decode or while the decoder did output something on EOF
1301 1301
    while (avpkt.size > 0 || (!pkt && ist->next_pts != ist->pts)) {
1302
        uint8_t *data_buf;
1303
        int data_size;
1302
        uint8_t *data_buf, *decoded_data_buf;
1303
        int data_size, decoded_data_size;
1304 1304
    handle_eof:
1305 1305
        ist->pts= ist->next_pts;
1306 1306

  
......
1309 1309
            fprintf(stderr, "Multiple frames in a packet from stream %d\n", pkt->stream_index);
1310 1310

  
1311 1311
        /* decode the packet if needed */
1312
        data_buf = NULL; /* fail safe */
1313
        data_size = 0;
1312
        decoded_data_buf = NULL; /* fail safe */
1313
        decoded_data_size= 0;
1314
        data_buf  = avpkt.data;
1315
        data_size = avpkt.size;
1314 1316
        subtitle_to_free = NULL;
1315 1317
        if (ist->decoding_needed) {
1316 1318
            switch(ist->st->codec->codec_type) {
......
1320 1322
                    av_free(samples);
1321 1323
                    samples= av_malloc(samples_size);
1322 1324
                }
1323
                data_size= samples_size;
1325
                decoded_data_size= samples_size;
1324 1326
                    /* XXX: could avoid copy if PCM 16 bits with same
1325 1327
                       endianness as CPU */
1326
                ret = avcodec_decode_audio3(ist->st->codec, samples, &data_size,
1328
                ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size,
1327 1329
                                            &avpkt);
1328 1330
                if (ret < 0)
1329 1331
                    goto fail_decode;
1330 1332
                avpkt.data += ret;
1331 1333
                avpkt.size -= ret;
1334
                data_size   = ret;
1332 1335
                /* Some bug in mpeg audio decoder gives */
1333
                /* data_size < 0, it seems they are overflows */
1334
                if (data_size <= 0) {
1336
                /* decoded_data_size < 0, it seems they are overflows */
1337
                if (decoded_data_size <= 0) {
1335 1338
                    /* no audio frame */
1336 1339
                    continue;
1337 1340
                }
1338
                data_buf = (uint8_t *)samples;
1339
                ist->next_pts += ((int64_t)AV_TIME_BASE/bps * data_size) /
1341
                decoded_data_buf = (uint8_t *)samples;
1342
                ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) /
1340 1343
                    (ist->st->codec->sample_rate * ist->st->codec->channels);
1341 1344
                break;}
1342 1345
            case CODEC_TYPE_VIDEO:
1343
                    data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
1346
                    decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
1344 1347
                    /* XXX: allocate picture correctly */
1345 1348
                    avcodec_get_frame_defaults(&picture);
1346 1349

  
......
1390 1393
                }
1391 1394
                break;
1392 1395
            }
1393
            data_buf = avpkt.data;
1394
            data_size = avpkt.size;
1395 1396
            ret = avpkt.size;
1396 1397
            avpkt.size = 0;
1397 1398
        }
......
1407 1408
            if (audio_volume != 256) {
1408 1409
                short *volp;
1409 1410
                volp = samples;
1410
                for(i=0;i<(data_size / sizeof(short));i++) {
1411
                for(i=0;i<(decoded_data_size / sizeof(short));i++) {
1411 1412
                    int v = ((*volp) * audio_volume + 128) >> 8;
1412 1413
                    if (v < -32768) v = -32768;
1413 1414
                    if (v >  32767) v = 32767;
......
1438 1439
                    //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE;
1439 1440

  
1440 1441
                    if (ost->encoding_needed) {
1442
                        assert(ist->decoding_needed);
1441 1443
                        switch(ost->st->codec->codec_type) {
1442 1444
                        case CODEC_TYPE_AUDIO:
1443
                            do_audio_out(os, ost, ist, data_buf, data_size);
1445
                            do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);
1444 1446
                            break;
1445 1447
                        case CODEC_TYPE_VIDEO:
1446 1448
                            do_video_out(os, ost, ist, &picture, &frame_size);

Also available in: Unified diff