cap_ffmpeg.patch

patch for 8bit uncompressed ffmpeg AVI - Martin Beckett, 2011-03-31 07:09 pm

Download (2.1 kB)

 
cap_ffmpeg.cpp Thu Mar 31 10:03:52 2011
476 476
            picture = avcodec_alloc_frame();
477 477

  
478 478
            rgb_picture.data[0] = (uint8_t*)cvAlloc(
479
                                    avpicture_get_size( PIX_FMT_BGR24,
479
                                    //avpicture_get_size( PIX_FMT_BGR24,
480
									avpicture_get_size( enc->pix_fmt,
480 481
                                    enc->width, enc->height ));
481 482
            avpicture_fill( (AVPicture*)&rgb_picture, rgb_picture.data[0],
482
                    PIX_FMT_BGR24, enc->width, enc->height );
483
                    // PIX_FMT_BGR24, enc->width, enc->height );
484
					enc->pix_fmt, enc->width, enc->height );
483 485

  
486
			// TODO do we want to generate an image of the same format as the source video or automatically convert to RGB
487
			int channels = 3;
488
			int depth = 8;
489
			if ( PIX_FMT_BGR24 == enc->pix_fmt ) {
490
				// 8,3
491
			} else if ( PIX_FMT_GRAY8 == enc->pix_fmt ) {
492
				channels = 1;
493
			}
484 494
            cvInitImageHeader( &frame, cvSize( enc->width,
485
                                       enc->height ), 8, 3, 0, 4 );
495
                                       enc->height ), depth, channels, 0, 4 );
486 496
            cvSetData( &frame, rgb_picture.data[0],
487 497
                               rgb_picture.linesize[0] );
488 498
            break;
......
597 607
                  video_st->codec->pix_fmt,
598 608
                  video_st->codec->width,
599 609
                  video_st->codec->height,
600
                  PIX_FMT_BGR24,
610
                  //PIX_FMT_BGR24,
611
				  video_st->codec->pix_fmt,
601 612
                  SWS_BICUBIC,
602 613
                  NULL, NULL, NULL);
603 614

  
......
1265 1276
      bitrate_scale = 128;
1266 1277
      break;
1267 1278
    case CODEC_ID_RAWVIDEO:
1279
		switch (fourcc) {
1280
			case 0x30303859: //Y800
1281
			case 0x20203859: //Y8
1282
			case 0x59455247: // GREY
1283
				codec_pix_fmt  = input_pix_fmt = PIX_FMT_GRAY8;
1284
				break;
1285
			default:
1286
				codec_pix_fmt  = input_pix_fmt;
1287
				break;
1288
		}
1289
		break;
1268 1290
    default:
1269 1291
        // good for lossy formats, MPEG, etc.
1270 1292
        codec_pix_fmt = PIX_FMT_YUV420P;