* Specify length of Group of Pictures as in API example.
* Don't hardcode PIX_FMT_YUV420P, but use the color space from the list of codec supported ones which has the best quality. * Maintain media_encode_info->flags by specifying whether a chunk contains a keyframe. According to the libavformat API example, all audio chunks are keyframes. For video chunks, use the fContext->coded_frame->key_frame flag. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39032 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
99841fe8dd
commit
88eddd3d71
@ -272,9 +272,13 @@ AVCodecEncoder::_Setup()
|
||||
// video size
|
||||
fContext->width = fInputFormat.u.raw_video.display.line_width;
|
||||
fContext->height = fInputFormat.u.raw_video.display.line_count;
|
||||
// fContext->gop_size = 12;
|
||||
fContext->gop_size = 12;
|
||||
// TODO: Fix pixel format or setup conversion method...
|
||||
fContext->pix_fmt = PIX_FMT_YUV420P;
|
||||
for (int i = 0; fCodec->pix_fmts[i] != PIX_FMT_NONE; i++) {
|
||||
// Use the last supported pixel format, which we hope is the
|
||||
// one with the best quality.
|
||||
fContext->pix_fmt = fCodec->pix_fmts[i];
|
||||
}
|
||||
|
||||
// TODO: Setup rate control:
|
||||
// fContext->rate_emu = 0;
|
||||
@ -551,6 +555,7 @@ AVCodecEncoder::_EncodeAudio(const uint8* buffer, size_t bufferSize,
|
||||
// Setup media_encode_info, most important is the time stamp.
|
||||
info->start_time = (bigtime_t)(fFramesWritten * 1000000LL
|
||||
/ fInputFormat.u.raw_audio.frame_rate);
|
||||
info->flags = B_MEDIA_KEY_FRAME;
|
||||
|
||||
// Write the chunk
|
||||
status_t ret = WriteChunk(fChunkBuffer, usedBytes, info);
|
||||
@ -590,13 +595,13 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount,
|
||||
fInputFormat.u.raw_video.display.line_count, fDstFrame.data,
|
||||
fDstFrame.linesize);
|
||||
|
||||
// TODO: Look into this... avcodec.h says we need to set it.
|
||||
fFrame->pts++;
|
||||
|
||||
// Encode one video chunk/frame.
|
||||
int usedBytes = avcodec_encode_video(fContext, fChunkBuffer,
|
||||
kDefaultChunkBufferSize, fFrame);
|
||||
|
||||
// avcodec.h says we need to set it.
|
||||
fFrame->pts++;
|
||||
|
||||
if (usedBytes < 0) {
|
||||
TRACE(" avcodec_encode_video() failed: %d\n", usedBytes);
|
||||
return B_ERROR;
|
||||
@ -616,6 +621,10 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount,
|
||||
info->start_time = (bigtime_t)(fFramesWritten * 1000000LL
|
||||
/ fInputFormat.u.raw_video.field_rate);
|
||||
|
||||
info->flags = 0;
|
||||
if (fContext->coded_frame->key_frame)
|
||||
info->flags |= B_MEDIA_KEY_FRAME;
|
||||
|
||||
// Write the chunk
|
||||
ret = WriteChunk(fChunkBuffer, usedBytes, info);
|
||||
if (ret != B_OK) {
|
||||
|
Loading…
Reference in New Issue
Block a user