Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,13 +263,37 @@ unsigned int CActiveAEStream::AddData(uint8_t* const *data, unsigned int offset, | |
} | ||
copied += minFrames; | ||
|
||
bool rawPktComplete = false; | ||
{ | ||
CSingleLock lock(*m_statsLock); | ||
m_currentBuffer->pkt->nb_samples += minFrames; | ||
m_bufferedTime += (double)minFrames / m_currentBuffer->pkt->config.sample_rate; | ||
if (m_format.m_dataFormat != AE_FMT_RAW) | ||
{ | ||
m_currentBuffer->pkt->nb_samples += minFrames; | ||
m_bufferedTime += (double)minFrames / m_currentBuffer->pkt->config.sample_rate; | ||
} | ||
else | ||
{ | ||
if (m_format.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_TRUEHD) | ||
{ | ||
m_currentBuffer->pkt->nb_samples += 2560; | ||
uint8_t highByte = (minFrames >> 8) & 0xFF; | ||
uint8_t lowByte = minFrames & 0xFF; | ||
memcpy(m_currentBuffer->pkt->data[0]+m_currentBuffer->pkt->nb_samples-2, &highByte, 1); | ||
This comment has been minimized.
Sorry, something went wrong.
fritsch
|
||
memcpy(m_currentBuffer->pkt->data[0]+m_currentBuffer->pkt->nb_samples-1, &lowByte, 1); | ||
m_bufferedTime += m_format.m_streamInfo.GetDuration() / 1000 / 24; | ||
if (m_currentBuffer->pkt->nb_samples / 2560 == 24) | ||
rawPktComplete = true; | ||
} | ||
else | ||
{ | ||
m_bufferedTime += m_format.m_streamInfo.GetDuration() / 1000; | ||
m_currentBuffer->pkt->nb_samples += minFrames; | ||
rawPktComplete = true; | ||
} | ||
} | ||
} | ||
|
||
if (m_currentBuffer->pkt->nb_samples == m_currentBuffer->pkt->max_nb_samples || m_format.m_dataFormat == AE_FMT_RAW) | ||
if (m_currentBuffer->pkt->nb_samples == m_currentBuffer->pkt->max_nb_samples || rawPktComplete) | ||
{ | ||
MsgStreamSample msgData; | ||
msgData.buffer = m_currentBuffer; | ||
|
6 comments
on commit adfa2b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, if you trust all version of compilers on all platforms from now to the future to do the right thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that was the question. I found it really curious that it seems that gcc uses memcpy itself internally for a simple assignment.
I think there are way, way less optimized compilers for ARM / whatever versions - so that we should go with the simple assignment version that I Prd.
I will test with gcc 4.9 just for fun, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't get me wrong. I am not against a direct assignment. just was curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am now also curious :-)
@MrMC could you compile test on an ARM machine?
Perhaps this code here:
#include <string.h>
#include <stdio.h>
int main()
{
char buffer[1024];
char src = 5;
for (int i = 0; i < 1023; ++i)
{
// Remove the following two for test 2
//buffer[i] = src;
//buffer[i+1] = buffer[i];
// Comment these two for test 2
memcpy(buffer + i, &src, 1);
memcpy(buffer + i + 1, &src, 1);
}
return buffer[0];
}
to assembly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang (darwin) arm64
test:
(__TEXT,__text) section
_main:
0000000100007ecc stp x28, x27, [sp, #-32]!
0000000100007ed0 stp x29, x30, [sp, #16]
0000000100007ed4 add x29, sp, #16
0000000100007ed8 sub sp, sp, xbmc#1088
0000000100007edc add x8, sp, #32
0000000100007ee0 movz w9, #0x5
0000000100007ee4 adrp x10, 1 ; 0x100007000
0000000100007ee8 ldr x10, [x10] ; literal pool symbol address: ___stack_chk_guard
0000000100007eec ldr x10, [x10]
0000000100007ef0 mov x0, x10
0000000100007ef4 str x10, [x8]
0000000100007ef8 str wzr, [sp, #52]
0000000100007efc strb w9, [sp, #51]
0000000100007f00 str wzr, [sp, #44]
0000000100007f04 str x8, [sp, #24]
0000000100007f08 str x0, [sp, #16]
0000000100007f0c ldr w8, [sp, #44]
0000000100007f10 cmp w8, xbmc#1023
0000000100007f14 b.ge 0x100007f4c
0000000100007f18 add x8, sp, #56
0000000100007f1c ldrsw x9, [sp, #44]
0000000100007f20 add x9, x8, x9
0000000100007f24 ldrb w10, [sp, #51]
0000000100007f28 strb w10, [x9]
0000000100007f2c ldrsw x9, [sp, #44]
0000000100007f30 add x8, x8, x9
0000000100007f34 ldrb w10, [sp, #51]
0000000100007f38 strb w10, [x8, #1]
0000000100007f3c ldr w8, [sp, #44]
0000000100007f40 add w8, w8, #1
0000000100007f44 str w8, [sp, #44]
0000000100007f48 b 0x100007f0c
0000000100007f4c adrp x8, 1 ; 0x100007000
0000000100007f50 ldr x8, [x8] ; literal pool symbol address: ___stack_chk_guard
0000000100007f54 ldrsb w0, [sp, #56]
0000000100007f58 ldr x8, [x8]
0000000100007f5c ldr x9, [sp, #24]
0000000100007f60 ldr x10, [x9]
0000000100007f64 cmp x8, x10
0000000100007f68 str w0, [sp, #12]
0000000100007f6c b.ne 0x100007f84
0000000100007f70 ldr w0, [sp, #12]
0000000100007f74 sub sp, x29, #16
0000000100007f78 ldp x29, x30, [sp, #16]
0000000100007f7c ldp x28, x27, [sp], #32
0000000100007f80 ret
0000000100007f84 bl 0x100007f88 ; symbol stub for: ___stack_chk_fail
S
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang (darwin) armv7
(__TEXT,__text) section
_main:
0000bf50 b580 push {r7, lr}
0000bf52 466f mov r7, sp
0000bf54 f5ad6d82 sub.w sp, sp, #0x410
0000bf58 b081 sub sp, #0x4
0000bf5a 2000 movs r0, #0x0
0000bf5c 2105 movs r1, #0x5
0000bf5e f24002a2 movw r2, #0xa2
0000bf62 f2c00200 movt r2, #0x0
0000bf66 447a add r2, pc
0000bf68 6812 ldr r2, [r2]
0000bf6a 6812 ldr r2, [r2]
0000bf6c f8472c04 str r2, [r7, #-4]
0000bf70 9003 str r0, [sp, #0xc]
0000bf72 f88d100b strb.w r1, [sp, #0xb]
0000bf76 9001 str r0, [sp, #0x4]
0000bf78 f24030ff movw r0, #0x3ff
0000bf7c 9901 ldr r1, [sp, #0x4]
0000bf7e 4281 cmp r1, r0
0000bf80 da0e bge 0xbfa0
0000bf82 a804 add r0, sp, #0x10
0000bf84 9901 ldr r1, [sp, #0x4]
0000bf86 4401 add r1, r0
0000bf88 f89d200b ldrb.w r2, [sp, #0xb]
0000bf8c 700a strb r2, [r1]
0000bf8e 9901 ldr r1, [sp, #0x4]
0000bf90 4408 add r0, r1
0000bf92 f89d100b ldrb.w r1, [sp, #0xb]
0000bf96 7041 strb r1, [r0, #0x1]
0000bf98 9801 ldr r0, [sp, #0x4]
0000bf9a 3001 adds r0, #0x1
0000bf9c 9001 str r0, [sp, #0x4]
0000bf9e e7eb b 0xbf78
0000bfa0 f2400060 movw r0, #0x60
0000bfa4 f2c00000 movt r0, #0x0
0000bfa8 4478 add r0, pc
0000bfaa 6800 ldr r0, [r0]
0000bfac f99d1010 ldrsb.w r1, [sp, #0x10]
0000bfb0 6800 ldr r0, [r0]
0000bfb2 f8572c04 ldr r2, [r7, #-4]
0000bfb6 4290 cmp r0, r2
0000bfb8 9100 str r1, [sp]
0000bfba d104 bne 0xbfc6
0000bfbc 9800 ldr r0, [sp]
0000bfbe f50d6d82 add.w sp, sp, #0x410
0000bfc2 b001 add sp, #0x4
0000bfc4 bd80 pop {r7, pc}
0000bfc6 f000e81a blx 0xbffc
That's already seconds isn't it? Why the / 1000?