Improve playback of VP9 codec

This commit is contained in:
samsamsam
2019-02-02 18:41:46 +01:00
committed by Thilo Graf
parent 0435571728
commit c298f20a69
18 changed files with 306 additions and 111 deletions

View File

@@ -88,31 +88,38 @@ int32_t InsertVideoPrivateDataHeader(uint8_t *data, int32_t payload_size)
FlushBits(&ld2);
return PES_PRIVATE_DATA_LENGTH + 1;
}
void UpdatePesHeaderPayloadSize(uint8_t *data, int32_t size)
{
if (size > MAX_PES_PACKET_SIZE || size < 0)
size = 0;
data[4] = size >> 8;
data[5] = size & 0xFF;
}
int32_t InsertPesHeader(uint8_t *data, int32_t size, uint8_t stream_id, uint64_t pts, int32_t pic_start_code)
{
BitPacker_t ld2 = {data, 0, 32};
if (size > (MAX_PES_PACKET_SIZE - 13))
PutBits(&ld2, 0x0, 8);
PutBits(&ld2, 0x0, 8);
PutBits(&ld2, 0x1, 8); // Start Code
PutBits(&ld2, stream_id, 8); // Stream_id = Audio Stream
if (size > 0)
{
size = -1; // unbounded
size += 3 + (pts != INVALID_PTS_VALUE ? 5 : 0) + (pic_start_code ? (5) : 0);
}
if (size > MAX_PES_PACKET_SIZE || size < 0)
{
size = 0; // unbounded
}
PutBits(&ld2, 0x0, 8);
PutBits(&ld2, 0x0, 8);
PutBits(&ld2, 0x1, 8); // Start Code
PutBits(&ld2, stream_id, 8); // Stream_id = Audio Stream
//4
if (-1 == size)
{
PutBits(&ld2, 0x0, 16);
}
else
{
PutBits(&ld2, size + 3 + (pts != INVALID_PTS_VALUE ? 5 : 0) + (pic_start_code ? (5) : 0), 16); // PES_packet_length
}
PutBits(&ld2, size, 16); // PES_packet_length
//6 = 4+2
PutBits(&ld2, 0x2, 2); // 10
PutBits(&ld2, 0x0, 2); // PES_Scrambling_control