libeplayer3: move width/height/framerate/timescale calculation to writers

This commit is contained in:
martii
2014-04-05 11:36:49 +02:00
parent 85bcfb4a17
commit ff13f75588
9 changed files with 27 additions and 105 deletions

View File

@@ -913,9 +913,7 @@ static int Write(Context_t *context, AudioVideoOut_t *out)
video = !strcmp("video", out->type);
audio = !strcmp("audio", out->type);
linuxdvb_printf(20,
"DataLength=%u Pts=%llu FrameRate=%f\n",
out->len, out->pts, out->frameRate);
linuxdvb_printf(20, "DataLength=%u Pts=%llu\n", out->len, out->pts);
linuxdvb_printf(20, "v%d a%d\n", video, audio);
if (video) {
@@ -942,11 +940,6 @@ static int Write(Context_t *context, AudioVideoOut_t *out)
call.data = out->data;
call.len = out->len;
call.Pts = out->pts;
call.FrameRate = out->frameRate;
call.FrameScale = out->timeScale;
call.Width = out->width;
call.Height = out->height;
call.Version = 0; // is unsingned char
if (writer->writeData)
res = writer->writeData(&call);
@@ -984,9 +977,6 @@ static int Write(Context_t *context, AudioVideoOut_t *out)
call.data = out->data;
call.len = out->len;
call.Pts = out->pts;
call.FrameRate = out->frameRate;
call.FrameScale = out->timeScale;
call.Version = 0; /* -1; unsigned char cannot be negative */
call.uNoOfChannels = out->uNoOfChannels;
call.uSampleRate = out->uSampleRate;

View File

@@ -121,7 +121,8 @@ static int writeData(WriterAVCallData_t *call)
divx_printf(10, "AudioPts %lld\n", call->Pts);
usecPerFrame = 1000000000 / call->FrameRate;
usecPerFrame = 1000000 / av_q2d(call->stream->r_frame_rate);
divx_printf(10, "Microsecends per frame = %d\n", usecPerFrame);
memset(FakeHeaders, 0, sizeof(FakeHeaders));

View File

@@ -124,8 +124,9 @@ static int writeData(WriterAVCallData_t *call)
return 0;
}
TimeDelta = call->FrameRate;
TimeScale = call->FrameScale;
TimeDelta = 1000.0 * av_q2d(call->stream->r_frame_rate); /* rational to double */
TimeScale = (TimeDelta < 23970) ? 1001 : 1000; /* fixme: revise this */
VideoPts = call->Pts;
h264_printf(10, "VideoPts %lld - %d %d\n", call->Pts, TimeDelta,
@@ -148,8 +149,7 @@ static int writeData(WriterAVCallData_t *call)
|| (call->data[0] == 0xff && call->data[1] == 0xff
&& call->data[2] == 0xff && call->data[3] == 0xff))) {
unsigned int PacketLength = 0;
unsigned int FakeStartCode =
(call->Version << 8) | PES_VERSION_FAKE_START_CODE;
unsigned int FakeStartCode = /* (call->Version << 8) | */ PES_VERSION_FAKE_START_CODE;
iov[ic++].iov_base = PesHeader;
if (initialHeader) {
initialHeader = 0;

View File

@@ -155,11 +155,12 @@ static int writeData(WriterAVCallData_t *call)
unsigned int crazyFramerate = 0;
struct iovec iov[2];
vc1_printf(10, "Framerate: %u\n", call->FrameRate);
vc1_printf(10, "biWidth: %d\n", call->Width);
vc1_printf(10, "biHeight: %d\n", call->Height);
vc1_printf(10, "Framerate: %f\n", 1000.0 * av_q2d(call->stream->r_frame_rate));
vc1_printf(10, "biWidth: %d\n", call->stream->codec->width);
vc1_printf(10, "biHeight: %d\n", call->stream->codec->height);
crazyFramerate = ((10000000.0 / av_q2d(call->stream->r_frame_rate)));
crazyFramerate = ((10000000.0 / call->FrameRate) * 1000.0);
vc1_printf(10, "crazyFramerate: %u\n", crazyFramerate);
memset(PesPayload, 0, sizeof(PesPayload));
@@ -175,14 +176,14 @@ static int writeData(WriterAVCallData_t *call)
PesPtr += WMV3_PRIVATE_DATA_LENGTH;
/* Metadata Header Struct A */
*PesPtr++ = (call->Height >> 0) & 0xff;
*PesPtr++ = (call->Height >> 8) & 0xff;
*PesPtr++ = (call->Height >> 16) & 0xff;
*PesPtr++ = call->Height >> 24;
*PesPtr++ = (call->Width >> 0) & 0xff;
*PesPtr++ = (call->Width >> 8) & 0xff;
*PesPtr++ = (call->Width >> 16) & 0xff;
*PesPtr++ = call->Width >> 24;
*PesPtr++ = (call->stream->codec->height >> 0) & 0xff;
*PesPtr++ = (call->stream->codec->height >> 8) & 0xff;
*PesPtr++ = (call->stream->codec->height >> 16) & 0xff;
*PesPtr++ = call->stream->codec->height >> 24;
*PesPtr++ = (call->stream->codec->width >> 0) & 0xff;
*PesPtr++ = (call->stream->codec->width >> 8) & 0xff;
*PesPtr++ = (call->stream->codec->width >> 16) & 0xff;
*PesPtr++ = call->stream->codec->width >> 24;
PesPtr += 12; /* Skip flag word and Struct B first 8 bytes */

View File

@@ -145,9 +145,10 @@ static int writeData(WriterAVCallData_t *call)
memcpy(private_data.privateData, call->stream->codec->extradata, call->stream->codec->extradata_size > WMV3_PRIVATE_DATA_LENGTH ? WMV3_PRIVATE_DATA_LENGTH : call->stream->codec->extradata_size);
private_data.width = call->Width;
private_data.height = call->Height;
private_data.framerate = call->FrameRate;
private_data.width = call->stream->codec->width;
private_data.height = call->stream->codec->height;
private_data.framerate = 1000.0 * av_q2d(call->stream->r_frame_rate); /* rational to double */
#define PES_MIN_HEADER_SIZE 9
if (initialHeader) {
@@ -156,7 +157,6 @@ static int writeData(WriterAVCallData_t *call)
unsigned int MetadataLength;
unsigned int crazyFramerate = 0;
wmv_printf(10, "Framerate: %u\n", private_data.framerate);
wmv_printf(10, "biWidth: %d\n", private_data.width);
wmv_printf(10, "biHeight: %d\n", private_data.height);