diff options
| author | Mickael Savinaud <savmickael@users.noreply.github.com> | 2011-09-27 12:14:11 +0000 |
|---|---|---|
| committer | Mickael Savinaud <savmickael@users.noreply.github.com> | 2011-09-27 12:14:11 +0000 |
| commit | a600d8f4e2c21ea0532d4af3dc6374b60b93c583 (patch) | |
| tree | 2711e66ac75b34b2bd7c39c880b8f438c6d7f050 /applications/codec | |
| parent | de7793e918ada457ae9ab59023454a47e768953b (diff) | |
[trunk] WIP: add basis for a new output management of the codestream information and index
Diffstat (limited to 'applications/codec')
| -rw-r--r-- | applications/codec/index.c | 105 | ||||
| -rw-r--r-- | applications/codec/index.h | 2 | ||||
| -rw-r--r-- | applications/codec/j2k_dump.c | 102 |
3 files changed, 15 insertions, 194 deletions
diff --git a/applications/codec/index.c b/applications/codec/index.c index 0c7c1e89..27a40740 100644 --- a/applications/codec/index.c +++ b/applications/codec/index.c @@ -392,109 +392,4 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) { return 0;
}
-/* ------------------------------------------------------------------------------------ */
-
-
-/**
-Dump the file info structure into a file
-@param stream output stream
-@param file_info informations read into the JPG2000 file
-@return Returns 0 if successful, returns 1 otherwise
-*/
-int dump_file_info(FILE* stream, opj_file_info_t *file_info)
-{
- /* IMAGE HEADER */
- if ( file_info->file_info_flag & OPJ_IMG_INFO ) {
- opj_image_header_t img_header = file_info->img_info;
- int compno;
-
- fprintf(stream, "Image info {\n");
- fprintf(stream, "\t x0=%d, y0=%d\n",img_header.x0, img_header.y0);
- fprintf(stream, "\t x1=%d, y1=%d\n",img_header.x1, img_header.y1);
- fprintf(stream, "\t numcomps=%d\n", img_header.numcomps);
- for (compno = 0; compno < img_header.numcomps; compno++) {
- opj_image_comp_header_t comp = img_header.comps[compno];
-
- fprintf(stream, "\t component %d {\n", compno);
- fprintf(stream, "\t\t dx=%d, dy=%d\n", comp.dx, comp.dy);
- fprintf(stream, "\t\t prec=%d\n", comp.prec);
- fprintf(stream, "\t\t sgnd=%d\n", comp.sgnd);
- fprintf(stream, "\t}\n");
- }
- fprintf(stream, "}\n");
- }
-
- /* CODESTREAM INFO */
- if ( file_info->file_info_flag & OPJ_J2K_INFO ) {
- opj_codestream_info_v2_t cstr_info = file_info->codestream_info;
- int tileno, compno, layno, bandno, resno, numbands;
-
- fprintf(stream, "Codestream info {\n");
- fprintf(stream, "\t tx0=%d, ty0=%d\n", cstr_info.tx0, cstr_info.ty0);
- fprintf(stream, "\t tdx=%d, tdy=%d\n", cstr_info.tdx, cstr_info.tdy);
- fprintf(stream, "\t tw=%d, th=%d\n", cstr_info.tw, cstr_info.th);
-
- for (tileno = 0; tileno < cstr_info.tw * cstr_info.th; tileno++) {
- opj_tile_info_v2_t tile_info = cstr_info.tile[tileno];
-
- fprintf(stream, "\t tile %d {\n", tileno);
- fprintf(stream, "\t\t csty=%x\n", tile_info.csty);
- fprintf(stream, "\t\t prg=%d\n", tile_info.prg);
- fprintf(stream, "\t\t numlayers=%d\n", tile_info.numlayers);
- fprintf(stream, "\t\t mct=%d\n", tile_info.mct);
- fprintf(stream, "\t\t rates=");
- for (layno = 0; layno < tile_info.numlayers; layno++) {
- fprintf(stream, "%.1f ", tile_info.rates[layno]);
- }
- fprintf(stream, "\n");
-
- for (compno = 0; compno < cstr_info.numcomps; compno++) {
- opj_tccp_info_t tccp_info = tile_info.tccp_info[compno];
-
- fprintf(stream, "\t\t comp %d {\n", compno);
- fprintf(stream, "\t\t\t csty=%x\n", tccp_info.csty);
- fprintf(stream, "\t\t\t numresolutions=%d\n", tccp_info.numresolutions);
- fprintf(stream, "\t\t\t cblkw=%d\n", tccp_info.cblkw);
- fprintf(stream, "\t\t\t cblkh=%d\n", tccp_info.cblkh);
- fprintf(stream, "\t\t\t cblksty=%x\n", tccp_info.cblksty);
- fprintf(stream, "\t\t\t qmfbid=%d\n", tccp_info.qmfbid);
- fprintf(stream, "\t\t\t qntsty=%d\n", tccp_info.qntsty);
- fprintf(stream, "\t\t\t numgbits=%d\n", tccp_info.numgbits);
- fprintf(stream, "\t\t\t roishift=%d\n", tccp_info.roishift);
-
-#ifdef TODO_MSD
- fprintf(stream, "\t\t\t stepsizes=");
- numbands = tccp_info->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp_info->numresolutions * 3 - 2;
- for (bandno = 0; bandno < numbands; bandno++) {
- fprintf(stream, "(%d,%d) ", tccp_info->stepsizes[bandno].mant,
- tccp_info->stepsizes[bandno].expn);
- }
- fprintf(stream, "\n");
-
- if (tccp_info->csty & J2K_CCP_CSTY_PRT) {
- fprintf(stream, " prcw=");
- for (resno = 0; resno < tccp_info->numresolutions; resno++) {
- fprintf(stream, "%d ", tccp_info->prcw[resno]);
- }
- fprintf(stream, "\n");
-
- fprintf(stream, " prch=");
- for (resno = 0; resno < tccp_info->numresolutions; resno++) {
- fprintf(stream, "%d ", tccp_info->prch[resno]);
- }
- fprintf(stream, "\n");
- }
-#endif
- fprintf(stream, "\t\t\t }\n");
- } /*end of component*/
- fprintf(stream, "\t\t }\n");
- } /*end of tile */
- fprintf(stream, "\t }\n");
- }
-
- if ( file_info->file_info_flag & OPJ_JP2_INFO ) {
- // not yet coded
- }
- return EXIT_SUCCESS;
-}
diff --git a/applications/codec/index.h b/applications/codec/index.h index aefce665..29f673a1 100644 --- a/applications/codec/index.h +++ b/applications/codec/index.h @@ -41,8 +41,6 @@ Write a structured index to a file */
int write_index_file(opj_codestream_info_t *cstr_info, char *index);
-int dump_file_info(FILE* stream, opj_file_info_t *file_info);
-
#ifdef __cplusplus
}
#endif
diff --git a/applications/codec/j2k_dump.c b/applications/codec/j2k_dump.c index 643240cf..37a74fd9 100644 --- a/applications/codec/j2k_dump.c +++ b/applications/codec/j2k_dump.c @@ -76,10 +76,6 @@ typedef struct img_folder{ /* -------------------------------------------------------------------------- */ /* Declarations */ - -static void j2k_dump_image(FILE *fd, opj_image_header_t * img); -static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_v2_t * cp); - int get_num_images(char *imgdirpath); int load_images(dircnt_t *dirptr, char *imgdirpath); int get_file_format(char *filename); @@ -378,9 +374,11 @@ int main(int argc, char *argv[]) opj_dparameters_t parameters; /* Decompression parameters */ opj_event_mgr_t event_mgr; /* Event manager */ - opj_file_info_t file_info; /* File info structure */ + opj_image_header_t img_header; /* Image info structure */ opj_codec_t* dinfo = NULL; /* Handle to a decompressor */ opj_stream_t *cio = NULL; /* Stream */ + opj_codestream_info_v2_t* cstr_info; + opj_codestream_index_t* cstr_index; OPJ_INT32 num_images, imageno; img_fol_t img_fol; @@ -510,7 +508,7 @@ int main(int argc, char *argv[]) } /* Read the main header of the codestream and if necessary the JP2 boxes*/ - if(! opj_read_header(cio, dinfo, &file_info, OPJ_IMG_INFO | OPJ_J2K_INFO)){ + if(! opj_read_header(cio, dinfo, &img_header)){ fprintf(stderr, "ERROR -> j2k_dump: failed to read the header\n"); opj_stream_destroy(cio); fclose(fsrc); @@ -519,9 +517,16 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + opj_dump_codec(dinfo, OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND, stdout ); + + cstr_info = opj_get_cstr_info(dinfo); + + cstr_index = opj_get_cstr_index(dinfo); + fprintf(stdout,"Setting decoding area to %d,%d,%d,%d\n", parameters.DA_x0, parameters.DA_y0, parameters.DA_x1, parameters.DA_y1); +#ifdef MSD /* FIXME WIP_MSD <*/ if (! opj_set_decode_area( dinfo, parameters.DA_x0, parameters.DA_y0, @@ -586,9 +591,7 @@ int main(int argc, char *argv[]) } } /* FIXME WIP_MSD >*/ - - /* Dump file informations from header */ - dump_file_info(fout, &file_info); +#endif /* close the byte stream */ opj_stream_destroy(cio); @@ -599,6 +602,9 @@ int main(int argc, char *argv[]) opj_destroy_codec(dinfo); } + /* destroy the image header */ + opj_image_header_destroy(&img_header); + } /* Close the output file */ @@ -606,81 +612,3 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } - - -static void j2k_dump_image(FILE *fd, opj_image_header_t * img) { - int compno; - fprintf(fd, "image {\n"); - fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1); - fprintf(fd, " numcomps=%d\n", img->numcomps); - for (compno = 0; compno < img->numcomps; compno++) { - opj_image_comp_header_t *comp = &img->comps[compno]; - fprintf(fd, " comp %d {\n", compno); - fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy); - fprintf(fd, " prec=%d\n", comp->prec); - /* fprintf(fd, " bpp=%d\n", comp->bpp); */ - fprintf(fd, " sgnd=%d\n", comp->sgnd); - fprintf(fd, " }\n"); - } - //fprintf(fd, " XTOsiz=%d, YTOsiz=%d, XTsiz=%d, YTsiz=%d\n", img->tile_x0, img->tile_y0, img->tile_width, img->tile_height); - //fprintf(fd, " Nb of tiles in x direction=%d, Nb of tiles in y direction=%d\n", img->nb_tiles_x, img->nb_tiles_y); - fprintf(fd, "}\n"); -} - -static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_v2_t * cp) { - int tileno, compno, layno, bandno, resno, numbands; - fprintf(fd, "coding parameters {\n"); - fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0); - fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy); - fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th); - for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { - opj_tcp_v2_t *tcp = &cp->tcps[tileno]; - fprintf(fd, " tile %d {\n", tileno); - fprintf(fd, " csty=%x\n", tcp->csty); - fprintf(fd, " prg=%d\n", tcp->prg); - fprintf(fd, " numlayers=%d\n", tcp->numlayers); - fprintf(fd, " mct=%d\n", tcp->mct); - fprintf(fd, " rates="); - for (layno = 0; layno < tcp->numlayers; layno++) { - fprintf(fd, "%.1f ", tcp->rates[layno]); - } - fprintf(fd, "\n"); - for (compno = 0; compno < img->numcomps; compno++) { - opj_tccp_t *tccp = &tcp->tccps[compno]; - fprintf(fd, " comp %d {\n", compno); - fprintf(fd, " csty=%x\n", tccp->csty); - fprintf(fd, " numresolutions=%d\n", tccp->numresolutions); - fprintf(fd, " cblkw=%d\n", tccp->cblkw); - fprintf(fd, " cblkh=%d\n", tccp->cblkh); - fprintf(fd, " cblksty=%x\n", tccp->cblksty); - fprintf(fd, " qmfbid=%d\n", tccp->qmfbid); - fprintf(fd, " qntsty=%d\n", tccp->qntsty); - fprintf(fd, " numgbits=%d\n", tccp->numgbits); - fprintf(fd, " roishift=%d\n", tccp->roishift); - fprintf(fd, " stepsizes="); - numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2; - for (bandno = 0; bandno < numbands; bandno++) { - fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant, - tccp->stepsizes[bandno].expn); - } - fprintf(fd, "\n"); - - if (tccp->csty & J2K_CCP_CSTY_PRT) { - fprintf(fd, " prcw="); - for (resno = 0; resno < tccp->numresolutions; resno++) { - fprintf(fd, "%d ", tccp->prcw[resno]); - } - fprintf(fd, "\n"); - fprintf(fd, " prch="); - for (resno = 0; resno < tccp->numresolutions; resno++) { - fprintf(fd, "%d ", tccp->prch[resno]); - } - fprintf(fd, "\n"); - } - fprintf(fd, " }\n"); - } /*end of component*/ - fprintf(fd, " }\n"); - } /*end of tile */ - fprintf(fd, "}\n"); -} - |
