rslt=get_qtable(params->quality2,&buf[header_yqtable],&buf[header_cqtable]);/// will copy both quantization tables
bpl=bp;/// save pointer to length (low byte)
if(rslt<0)returnrslt;/// bad quality table
bp++;
bp=header_sof;
buf[bp++]=0x8;/// 8bpp
buf[bp++]=0xff;buf[bp++]=0xc0;
buf[bp++]=params->height>>8;buf[bp++]=params->height;/// big endian height
buf[bp++]=0;/// high byte length - always 0
buf[bp++]=params->width>>8;buf[bp++]=params->width;/// big endian width
bpl=bp;/// save pointer to length (low byte)
/// copy SOF0 (constants combined with bayer shift for jp4diff/jp4hdr)
bp++;
switch(params->color){
buf[bp++]=0x8;/// 8bpp
caseCOLORMODE_MONO6:/// monochrome, (4:2:0),
buf[bp++]=params->height>>8;buf[bp++]=params->height;/// big endian height
caseCOLORMODE_COLOR:/// color, 4:2:0, 18x18(old)
buf[bp++]=params->width>>8;buf[bp++]=params->width;/// big endian width
caseCOLORMODE_COLOR20:/// color, 4:2:0, 20x20, middle of the tile (not yet implemented)
/// copy SOF0 (constants combined with bayer shift for jp4diff/jp4hdr)
caseCOLORMODE_JP46:/// jp4, original (4:2:0)
switch(params->color){
HEADER_COPY_SOF(sof_color6);
caseCOLORMODE_MONO6:/// monochrome, (4:2:0),
break;
caseCOLORMODE_COLOR:/// color, 4:2:0, 18x18(old)
caseCOLORMODE_MONO4:/// monochrome, 4 blocks (but still with 2x2 macroblocks)
caseCOLORMODE_COLOR20:/// color, 4:2:0, 20x20, middle of the tile (not yet implemented)
HEADER_COPY_SOF(sof_mono4);
caseCOLORMODE_JP46:/// jp4, original (4:2:0)
break;
HEADER_COPY_SOF(sof_color6);
caseCOLORMODE_JP4:/// jp4, 4 blocks
break;
HEADER_COPY_SOF(sof_jp4);
caseCOLORMODE_MONO4:/// monochrome, 4 blocks (but still with 2x2 macroblocks)
break;
HEADER_COPY_SOF(sof_mono4);
caseCOLORMODE_JP46DC:/// jp4, dc -improved (4:2:0)
break;
HEADER_COPY_SOF(sof_jp46dc);
caseCOLORMODE_JP4:/// jp4, 4 blocks
break;
HEADER_COPY_SOF(sof_jp4);
caseCOLORMODE_JP4DC:/// jp4, 4 blocks, dc -improved
break;
HEADER_COPY_SOF(sof_jp4dc);
caseCOLORMODE_JP46DC:/// jp4, dc -improved (4:2:0)
break;
HEADER_COPY_SOF(sof_jp46dc);
caseCOLORMODE_JP4DIFF:/// jp4, 4 blocks, differential red := (R-G1), blue:=(B-G1), green=G1, green2 (G2-G1). G1 is defined by Bayer shift, any pixel can be used
break;
caseCOLORMODE_JP4DIFF2:/// jp4, 4 blocks, differential, divide differences by 2: red := (R-G1)/2, blue:=(B-G1)/2, green=G1, green2 (G2-G1)/2
caseCOLORMODE_JP4DC:/// jp4, 4 blocks, dc -improved
HEADER_COPY_SOF(sof_jp4diff);
HEADER_COPY_SOF(sof_jp4dc);
//header_sof
break;
//bshift
caseCOLORMODE_JP4DIFF:/// jp4, 4 blocks, differential red := (R-G1), blue:=(B-G1), green=G1, green2 (G2-G1). G1 is defined by Bayer shift, any pixel can be used
buf[header_sof+12+3*((4-params->byrshift)&3)]=0;/// set quantization table 0 for the "base color"
caseCOLORMODE_JP4DIFF2:/// jp4, 4 blocks, differential, divide differences by 2: red := (R-G1)/2, blue:=(B-G1)/2, green=G1, green2 (G2-G1)/2
break;
HEADER_COPY_SOF(sof_jp4diff);
caseCOLORMODE_JP4HDR:/// jp4, 4 blocks, differential HDR: red := (R-G1), blue:=(B-G1), green=G1, green2 (high gain)=G2) (G1 and G2 - diagonally opposite)
/// copy SOS0 (constants combined with bayer shift for jp4diff/jp4hdr)
caseCOLORMODE_MONO6:/// monochrome, (4:2:0),
header_sos=bp;
caseCOLORMODE_COLOR:/// color, 4:2:0, 18x18(old)
buf[bp++]=0xff;buf[bp++]=0xda;/// SOS tag
caseCOLORMODE_COLOR20:/// color, 4:2:0, 20x20, middle of the tile (not yet implemented)
buf[bp++]=0;/// high byte length - always 0
caseCOLORMODE_JP46:/// jp4, original (4:2:0)
switch(params->color){
HEADER_COPY_SOS(sos_color6);
caseCOLORMODE_MONO6:/// monochrome, (4:2:0),
break;
caseCOLORMODE_COLOR:/// color, 4:2:0, 18x18(old)
caseCOLORMODE_MONO4:/// monochrome, 4 blocks (but still with 2x2 macroblocks)
caseCOLORMODE_COLOR20:/// color, 4:2:0, 20x20, middle of the tile (not yet implemented)
HEADER_COPY_SOS(sos_mono4);
caseCOLORMODE_JP46:/// jp4, original (4:2:0)
break;
HEADER_COPY_SOS(sos_color6);
caseCOLORMODE_JP4:/// jp4, 4 blocks
break;
HEADER_COPY_SOS(sos_jp4);
caseCOLORMODE_MONO4:/// monochrome, 4 blocks (but still with 2x2 macroblocks)
break;
HEADER_COPY_SOS(sos_mono4);
caseCOLORMODE_JP46DC:/// jp4, dc -improved (4:2:0)
break;
HEADER_COPY_SOS(sos_jp46dc);
caseCOLORMODE_JP4:/// jp4, 4 blocks
break;
HEADER_COPY_SOS(sos_jp4);
caseCOLORMODE_JP4DC:/// jp4, 4 blocks, dc -improved
break;
HEADER_COPY_SOS(sos_jp4dc);
caseCOLORMODE_JP46DC:/// jp4, dc -improved (4:2:0)
break;
HEADER_COPY_SOS(sos_jp46dc);
caseCOLORMODE_JP4DIFF:/// jp4, 4 blocks, differential red := (R-G1), blue:=(B-G1), green=G1, green2 (G2-G1). G1 is defined by Bayer shift, any pixel can be used
break;
caseCOLORMODE_JP4DIFF2:/// jp4, 4 blocks, differential, divide differences by 2: red := (R-G1)/2, blue:=(B-G1)/2, green=G1, green2 (G2-G1)/2
caseCOLORMODE_JP4DC:/// jp4, 4 blocks, dc -improved
HEADER_COPY_SOS(sos_jp4diff);
HEADER_COPY_SOS(sos_jp4dc);
buf[header_sos+6+2*((4-params->byrshift)&3)]=0;/// set huffman table 0 for the "base color"
break;
break;
caseCOLORMODE_JP4DIFF:/// jp4, 4 blocks, differential red := (R-G1), blue:=(B-G1), green=G1, green2 (G2-G1). G1 is defined by Bayer shift, any pixel can be used
caseCOLORMODE_JP4HDR:/// jp4, 4 blocks, differential HDR: red := (R-G1), blue:=(B-G1), green=G1, green2 (high gain)=G2) (G1 and G2 - diagonally opposite)
caseCOLORMODE_JP4DIFF2:/// jp4, 4 blocks, differential, divide differences by 2: red := (R-G1)/2, blue:=(B-G1)/2, green=G1, green2 (G2-G1)/2
* move below two lines to circbuf_all_lseek to remove ccam_dma_buf_ptr and simplify dependencies
rp= (offset >>2) & (~7); // convert to index to long, align to 32-bytes
fp = (struct interframe_params_t *) &ccam_dma_buf_ptr[X313_BUFFSUB(rp, 8)]; //! 32 bytes before the frame pointer, may roll-over to the end of ccam_dma_buf_ptr
*/
//if ((fp->signffff != 0xffff) || //! signature is overwritten
if((fp->signffff!=MARKER_FFFF)||//! signature is overwritten
((fp->timestamp_sec)&X313_LENGTH_MASK))return-EINVAL;//! acquisition of this frame is not done yet - length word high byte is non-zero
///FIXME: pp_index=fp->past_index; /// unsigned short
/// if (pp_index>=PASTPARS_SAVE_ENTRIES) return -EINVAL; /// wrong index