MCPcopy Create free account
hub / github.com/LibRaw/LibRaw / open_datastream

Method open_datastream

src/utils/open.cpp:466–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464const int foveon_count = sizeof(foveon_data) / sizeof(foveon_data[0]);
465
466int LibRaw::open_datastream(LibRaw_abstract_datastream *stream)
467{
468
469 if (!stream)
470 return ENOENT;
471 if (!stream->valid())
472 return LIBRAW_IO_ERROR;
473 if ((stream->size() > (INT64)LIBRAW_MAX_DNG_RAW_FILE_SIZE)
474 && (stream->size() > (INT64)LIBRAW_MAX_NONDNG_RAW_FILE_SIZE) &&
475 (stream->size() > (INT64)LIBRAW_MAX_CR3_RAW_FILE_SIZE)
476 )
477 return LIBRAW_TOO_BIG;
478
479 recycle();
480 if (callbacks.pre_identify_cb)
481 {
482 int r = (callbacks.pre_identify_cb)(this);
483 if (r == 1)
484 goto final;
485 }
486
487 try
488 {
489 ID.input = stream;
490 SET_PROC_FLAG(LIBRAW_PROGRESS_OPEN);
491
492 identify();
493
494 // Fuji layout files: either DNG or unpacked_load_raw should be used
495 if (libraw_internal_data.internal_output_params.fuji_width || libraw_internal_data.unpacker_data.fuji_layout)
496 {
497 if (!imgdata.idata.dng_version && load_raw != &LibRaw::unpacked_load_raw
498 && load_raw != &LibRaw::unpacked_load_raw_FujiDBP
499 && load_raw != &LibRaw::unpacked_load_raw_fuji_f700s20
500 )
501 return LIBRAW_FILE_UNSUPPORTED;
502 }
503 // Remove unsupported Nikon thumbnails
504 if (makeIs(LIBRAW_CAMERAMAKER_Nikon) &&
505 (!strncasecmp(imgdata.idata.model, "Z 8", 3) || !strcasecmp(imgdata.idata.model, "Z f")
506 || !strncasecmp(imgdata.idata.model, "Z6_3", 4))
507 &&
508 imgdata.thumbs_list.thumbcount > 1)
509 {
510 int tgtidx = 0;
511 for (int idx = 0; idx < imgdata.thumbs_list.thumbcount && idx < LIBRAW_THUMBNAIL_MAXCOUNT; idx++)
512 {
513 int bps = imgdata.thumbs_list.thumblist[idx].tmisc & 0x1f;
514 if (bps > 8) // remove high-bit thumbs
515 {
516 // nothing: just skip this item
517 }
518 else
519 {
520 if (tgtidx < idx)
521 {
522 memmove(&imgdata.thumbs_list.thumblist[tgtidx], &imgdata.thumbs_list.thumblist[idx],
523 sizeof(imgdata.thumbs_list.thumblist[idx]));

Callers

nothing calls this directly

Calls 7

FCFunction · 0.85
freeFunction · 0.85
callocFunction · 0.85
seekMethod · 0.80
readMethod · 0.80
validMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected