📄 gethdr.c
字号:
//////////////////////
// deng , comment all
//#include <stdio.h>
//#include "config.h"
//#include "global.h"
/* private prototypes */
//static void getpicturehdr _ANSI_ARGS_((void));
//int getheader()
//{
// unsigned int gob;
/* look for startcode */
// gob = getbits(5);
// if (gob == SEC)
// return 0;
// if (gob == 0) {
// getpicturehdr();
// if (syntax_arith_coding) /* reset decoder after receiving */
// decoder_reset(); /* fixed length PSC string */
// }
// return gob + 1;
//}
/* decode picture header */
/*
static void getpicturehdr()
{
int pos;
static int prev_temp_ref;
pos = ld->bitcnt;
prev_temp_ref = temp_ref;
temp_ref = 0 ;
trd = temp_ref - prev_temp_ref;
if (trd < 0)
trd += 256;
if( trd == 0 ) trd = 1 ;
pict_type = getbits(1);
mv_outside_frame = 1 ;
long_vectors = (mv_outside_frame ? 1 : 0);
syntax_arith_coding = 1 ;
adv_pred_mode = getbits(1);
mv_outside_frame = (adv_pred_mode ? 1 : mv_outside_frame);
pb_frame = 0 ;
quant = getbits(5);
}
*/
//////////////////////////////
//
// deng modify 2001-nov
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "tmndec.h"
#include "global.h"
#include "sim.h"
/* private prototypes */
static void getpicturehdr _ANSI_ARGS_((void));
/* align to start of next startcode */
void startcode()
{
/* search for new picture start code */
while (showbits(PSC_LENGTH)!=1l)
flushbits(1);
}
/*
* decode headers from one input stream
* until an End of Sequence or picture start code
* is found
*/
int getheader()
{
unsigned int code, gob;
/* look for startcode */
startcode();
code = getbits(PSC_LENGTH);
gob = getbits(5);
if (gob == SEC)
return 0;
if (gob == 0) {
getpicturehdr();
if (syntax_arith_coding) /* reset decoder after receiving */
decoder_reset(); /* fixed length PSC string */
}
return gob + 1;
}
/* decode picture header */
static void getpicturehdr()
{
int pos, pei, tmp;
int prev_temp_ref; // deng, add
pos = ld->bitcnt;
prev_temp_ref = temp_ref;
temp_ref = getbits(8);
trd = temp_ref - prev_temp_ref;
if (trd < 0)
trd += 256;
tmp = getbits(1); /* always "1" */
if (!tmp)
printf("warning: spare in picture header should be \"1\"\n");
tmp = getbits(1); /* always "0" */
if (tmp)
printf("warning: H.261 distinction bit should be \"0\"\n");
tmp = getbits(1); /* split_screen_indicator */
if (tmp) {
printf("error: split-screen not supported in this version\n");
exit (-1);
}
tmp = getbits(1); /* document_camera_indicator */
if (tmp)
printf("warning: document camera indicator not supported in this version\n");
tmp = getbits(1); /* freeze_picture_release */
if (tmp)
printf("warning: frozen picture not supported in this version\n");
source_format = getbits(3);
pict_type = getbits(1);
mv_outside_frame = getbits(1);
long_vectors = (mv_outside_frame ? 1 : 0);
syntax_arith_coding = getbits(1);
adv_pred_mode = getbits(1);
mv_outside_frame = (adv_pred_mode ? 1 : mv_outside_frame);
pb_frame = getbits(1);
quant = getbits(5);
tmp = getbits(1);
if (tmp) {
printf("error: CPM not supported in this version\n");
exit(-1);
}
if (pb_frame) {
trb = getbits(3);
bquant = getbits(2);
}
else {
trb = 0;
}
#ifdef USE_TIME
if (framerate > 0 && trd > 0)
doframerate(0);
#endif
pei = getbits(1);
pspare:
if (pei) {
/* extra info for possible future backward compatible additions */
getbits(8); /* not used */
pei = getbits(1);
if (pei) goto pspare; /* keep on reading pspare until pei=0 */
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -