mirror of
https://github.com/mpv-player/mpv
synced 2025-01-16 22:37:28 +01:00
Use AV_RB* instead of custom variants.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25725 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
7ce9faabbe
commit
0a2a626342
30
stream/pnm.c
30
stream/pnm.c
@ -44,6 +44,8 @@
|
|||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "libavutil/intreadwrite.h"
|
||||||
|
|
||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
#include "libmpdemux/demuxer.h"
|
#include "libmpdemux/demuxer.h"
|
||||||
#include "help_mp.h"
|
#include "help_mp.h"
|
||||||
@ -103,16 +105,6 @@ struct pnm_s {
|
|||||||
unsigned int packet; /* number of last recieved packet */
|
unsigned int packet; /* number of last recieved packet */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* utility macros
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
|
|
||||||
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
|
|
||||||
(((uint8_t*)(x))[1] << 16) | \
|
|
||||||
(((uint8_t*)(x))[2] << 8) | \
|
|
||||||
((uint8_t*)(x))[3])
|
|
||||||
|
|
||||||
/* D means direct (no pointer) */
|
/* D means direct (no pointer) */
|
||||||
#define BE_16D(x) ((x & 0xff00) >> 8)|((x & 0x00ff) << 8)
|
#define BE_16D(x) ((x & 0xff00) >> 8)|((x & 0x00ff) << 8)
|
||||||
|
|
||||||
@ -324,8 +316,8 @@ static int pnm_get_chunk(pnm_t *p,
|
|||||||
|
|
||||||
max -= PREAMBLE_SIZE;
|
max -= PREAMBLE_SIZE;
|
||||||
|
|
||||||
*chunk_type = BE_32(data);
|
*chunk_type = AV_RB32(data);
|
||||||
chunk_size = BE_32(data+4);
|
chunk_size = AV_RB32(data+4);
|
||||||
|
|
||||||
switch (*chunk_type) {
|
switch (*chunk_type) {
|
||||||
case PNA_TAG:
|
case PNA_TAG:
|
||||||
@ -350,7 +342,7 @@ static int pnm_get_chunk(pnm_t *p,
|
|||||||
return -1;
|
return -1;
|
||||||
rm_read (p->s, ptr+2, 1);
|
rm_read (p->s, ptr+2, 1);
|
||||||
max = -1;
|
max = -1;
|
||||||
n=BE_16(ptr+1);
|
n=AV_RB16(ptr+1);
|
||||||
if (max < n)
|
if (max < n)
|
||||||
return -1;
|
return -1;
|
||||||
rm_read (p->s, ptr+3, n);
|
rm_read (p->s, ptr+3, n);
|
||||||
@ -686,7 +678,7 @@ static int pnm_get_stream_chunk(pnm_t *p) {
|
|||||||
/* a server message */
|
/* a server message */
|
||||||
if (p->buffer[0] == 'X')
|
if (p->buffer[0] == 'X')
|
||||||
{
|
{
|
||||||
int size=BE_16(&p->buffer[1]);
|
int size=AV_RB16(&p->buffer[1]);
|
||||||
|
|
||||||
rm_read (p->s, &p->buffer[8], size-5);
|
rm_read (p->s, &p->buffer[8], size-5);
|
||||||
p->buffer[size+3]=0;
|
p->buffer[size+3]=0;
|
||||||
@ -726,8 +718,8 @@ static int pnm_get_stream_chunk(pnm_t *p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check offsets */
|
/* check offsets */
|
||||||
fof1=BE_16(&p->buffer[1]);
|
fof1=AV_RB16(&p->buffer[1]);
|
||||||
fof2=BE_16(&p->buffer[3]);
|
fof2=AV_RB16(&p->buffer[3]);
|
||||||
if (fof1 != fof2)
|
if (fof1 != fof2)
|
||||||
{
|
{
|
||||||
mp_msg(MSGT_OPEN, MSGL_ERR, "input_pnm: frame offsets are different: 0x%04x 0x%04x\n",fof1,fof2);
|
mp_msg(MSGT_OPEN, MSGL_ERR, "input_pnm: frame offsets are different: 0x%04x 0x%04x\n",fof1,fof2);
|
||||||
@ -735,7 +727,7 @@ static int pnm_get_stream_chunk(pnm_t *p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get first index */
|
/* get first index */
|
||||||
p->seq_current[0]=BE_16(&p->buffer[5]);
|
p->seq_current[0]=AV_RB16(&p->buffer[5]);
|
||||||
|
|
||||||
/* now read the rest of stream chunk */
|
/* now read the rest of stream chunk */
|
||||||
n = rm_read (p->s, &p->recv[5], fof1-5);
|
n = rm_read (p->s, &p->recv[5], fof1-5);
|
||||||
@ -745,7 +737,7 @@ static int pnm_get_stream_chunk(pnm_t *p) {
|
|||||||
p->seq_current[1]=p->recv[5];
|
p->seq_current[1]=p->recv[5];
|
||||||
|
|
||||||
/* get timestamp */
|
/* get timestamp */
|
||||||
p->ts_current=BE_32(&p->recv[6]);
|
p->ts_current=AV_RB32(&p->recv[6]);
|
||||||
|
|
||||||
/* get stream number */
|
/* get stream number */
|
||||||
stream=pnm_calc_stream(p);
|
stream=pnm_calc_stream(p);
|
||||||
@ -758,7 +750,7 @@ static int pnm_get_stream_chunk(pnm_t *p) {
|
|||||||
p->recv[0]=0; /* object version */
|
p->recv[0]=0; /* object version */
|
||||||
p->recv[1]=0;
|
p->recv[1]=0;
|
||||||
|
|
||||||
fof2=BE_16(&fof2);
|
fof2=AV_RB16(&fof2);
|
||||||
memcpy(&p->recv[2], &fof2, 2);
|
memcpy(&p->recv[2], &fof2, 2);
|
||||||
/*p->recv[2]=(fof2>>8)%0xff;*/ /* length */
|
/*p->recv[2]=(fof2>>8)%0xff;*/ /* length */
|
||||||
/*p->recv[3]=(fof2)%0xff;*/
|
/*p->recv[3]=(fof2)%0xff;*/
|
||||||
|
Loading…
Reference in New Issue
Block a user