* Implemented calculating the correct display aspect ratio.
* Removed some dead code. * Fixed a style violation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31479 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -256,12 +256,6 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
|
|||||||
|
|
||||||
// Get a pointer to the AVCodecContext for the stream at streamIndex.
|
// Get a pointer to the AVCodecContext for the stream at streamIndex.
|
||||||
AVCodecContext* codecContext = fStream->codec;
|
AVCodecContext* codecContext = fStream->codec;
|
||||||
// NOTE: Experimenting with opening the AVCodec to see if I get more
|
|
||||||
// AVCodecContext fields filled out. Doesn't seem to make a difference
|
|
||||||
// for extradata for example.
|
|
||||||
// AVCodec* codec = avcodec_find_decoder(codecContext->codec_id);
|
|
||||||
// bool codecOpened = avcodec_open(codecContext, codec) == 0;
|
|
||||||
// TRACE(" codec opened: %d\n", codecOpened);
|
|
||||||
AVStream* stream = fStream;
|
AVStream* stream = fStream;
|
||||||
|
|
||||||
// initialize the media_format for this stream
|
// initialize the media_format for this stream
|
||||||
@@ -352,7 +346,8 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
|
|||||||
// codecTag = 0x2000;
|
// codecTag = 0x2000;
|
||||||
// break;
|
// break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "ffmpeg codecTag is null, codec_id unknown 0x%lx\n", codecContext->codec_id);
|
fprintf(stderr, "ffmpeg codecTag is null, codec_id "
|
||||||
|
"unknown 0x%x\n", codecContext->codec_id);
|
||||||
// TODO: Add more...
|
// TODO: Add more...
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -430,7 +425,7 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
|
|||||||
|
|
||||||
// Read one packet and mark it for later re-use. (So our first
|
// Read one packet and mark it for later re-use. (So our first
|
||||||
// GetNextChunk() call does not read another packet.)
|
// GetNextChunk() call does not read another packet.)
|
||||||
if ( _NextPacket(true) == B_OK) {
|
if (_NextPacket(true) == B_OK) {
|
||||||
TRACE(" successfully determined audio buffer size: %d\n",
|
TRACE(" successfully determined audio buffer size: %d\n",
|
||||||
fPacket.size);
|
fPacket.size);
|
||||||
format->u.raw_audio.buffer_size = fPacket.size;
|
format->u.raw_audio.buffer_size = fPacket.size;
|
||||||
@@ -475,16 +470,33 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
|
|||||||
format->u.encoded_video.output.orientation
|
format->u.encoded_video.output.orientation
|
||||||
= B_VIDEO_TOP_LEFT_RIGHT;
|
= B_VIDEO_TOP_LEFT_RIGHT;
|
||||||
|
|
||||||
// TODO: Implement aspect ratio for real
|
// Calculate the display aspect ratio
|
||||||
|
AVRational displayAspectRatio;
|
||||||
|
if (codecContext->sample_aspect_ratio.num != 0) {
|
||||||
|
// TODO: Maybe it would be more useful to change the meaning
|
||||||
|
// of pixel_width/height_aspect to mean the pixel width
|
||||||
|
// scale...
|
||||||
|
av_reduce(&displayAspectRatio.num, &displayAspectRatio.den,
|
||||||
|
codecContext->width
|
||||||
|
* codecContext->sample_aspect_ratio.num,
|
||||||
|
codecContext->height
|
||||||
|
* codecContext->sample_aspect_ratio.den,
|
||||||
|
1024 * 1024);
|
||||||
|
TRACE(" pixel aspect ratio: %d/%d, "
|
||||||
|
"display aspect ratio: %d/%d\n",
|
||||||
|
codecContext->sample_aspect_ratio.num,
|
||||||
|
codecContext->sample_aspect_ratio.den,
|
||||||
|
displayAspectRatio.num, displayAspectRatio.den);
|
||||||
|
} else {
|
||||||
|
av_reduce(&displayAspectRatio.num, &displayAspectRatio.den,
|
||||||
|
codecContext->width, codecContext->height, 1024 * 1024);
|
||||||
|
TRACE(" no display aspect ratio (%d/%d)\n",
|
||||||
|
displayAspectRatio.num, displayAspectRatio.den);
|
||||||
|
}
|
||||||
format->u.encoded_video.output.pixel_width_aspect
|
format->u.encoded_video.output.pixel_width_aspect
|
||||||
= 1;//stream->sample_aspect_ratio.num;
|
= displayAspectRatio.num;
|
||||||
format->u.encoded_video.output.pixel_height_aspect
|
format->u.encoded_video.output.pixel_height_aspect
|
||||||
= 1;//stream->sample_aspect_ratio.den;
|
= displayAspectRatio.den;
|
||||||
|
|
||||||
TRACE(" pixel width/height aspect: %d/%d or %.4f\n",
|
|
||||||
stream->sample_aspect_ratio.num,
|
|
||||||
stream->sample_aspect_ratio.den,
|
|
||||||
av_q2d(stream->sample_aspect_ratio));
|
|
||||||
|
|
||||||
format->u.encoded_video.output.display.format
|
format->u.encoded_video.output.display.format
|
||||||
= pixfmt_to_colorspace(codecContext->pix_fmt);
|
= pixfmt_to_colorspace(codecContext->pix_fmt);
|
||||||
@@ -516,9 +528,6 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
|
|||||||
TRACE(" get_buffer(): %p\n", codecContext->get_buffer);
|
TRACE(" get_buffer(): %p\n", codecContext->get_buffer);
|
||||||
TRACE(" release_buffer(): %p\n", codecContext->release_buffer);
|
TRACE(" release_buffer(): %p\n", codecContext->release_buffer);
|
||||||
|
|
||||||
// if (codecOpened)
|
|
||||||
// avcodec_close(codecContext);
|
|
||||||
|
|
||||||
#ifdef TRACE_AVFORMAT_READER
|
#ifdef TRACE_AVFORMAT_READER
|
||||||
char formatString[512];
|
char formatString[512];
|
||||||
if (string_for_format(*format, formatString, sizeof(formatString)))
|
if (string_for_format(*format, formatString, sizeof(formatString)))
|
||||||
|
|||||||
Reference in New Issue
Block a user