mirror of
https://github.com/simon987/libscan.git
synced 2025-04-08 05:16:41 +00:00
fixes
This commit is contained in:
parent
3c7887db51
commit
e6323e28d0
@ -36,7 +36,7 @@ ExternalProject_Add(
|
|||||||
add_library(
|
add_library(
|
||||||
scan
|
scan
|
||||||
libscan/util.c libscan/util.h
|
libscan/util.c libscan/util.h
|
||||||
libscan/scan.c libscan/scan.h
|
libscan/scan.h
|
||||||
libscan/macros.h
|
libscan/macros.h
|
||||||
|
|
||||||
libscan/text/text.c libscan/text/text.h
|
libscan/text/text.c libscan/text/text.h
|
||||||
@ -101,16 +101,3 @@ target_include_directories(
|
|||||||
${LIBXML2_INCLUDE_DIR}
|
${LIBXML2_INCLUDE_DIR}
|
||||||
${FFMPEG_INCLUDE_DIR}
|
${FFMPEG_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# test executable
|
|
||||||
add_executable(
|
|
||||||
scan_test
|
|
||||||
test/main.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
|
||||||
scan_test
|
|
||||||
scan
|
|
||||||
)
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
*(wip)*
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
vcpkg install libarchive pthread tesseract libxml2 ffmpeg
|
vcpkg install libarchive pthread tesseract libxml2 ffmpeg
|
||||||
|
@ -240,10 +240,14 @@ void parse_media_format_ctx(scan_media_ctx_t *ctx, AVFormatContext *pFormatCtx,
|
|||||||
|
|
||||||
if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||||
if (audio_stream == -1) {
|
if (audio_stream == -1) {
|
||||||
meta_line_t *meta_audio = malloc(sizeof(meta_line_t));
|
const AVCodecDescriptor *desc = avcodec_descriptor_get(stream->codecpar->codec_id);
|
||||||
meta_audio->key = MetaMediaAudioCodec;
|
|
||||||
meta_audio->int_val = stream->codecpar->codec_id;
|
if (desc != NULL) {
|
||||||
APPEND_META(doc, meta_audio)
|
meta_line_t *meta_audio = malloc(sizeof(meta_line_t));
|
||||||
|
meta_audio->key = MetaMediaAudioCodec;
|
||||||
|
strcpy(meta_audio->str_val, desc->name);
|
||||||
|
APPEND_META(doc, meta_audio)
|
||||||
|
}
|
||||||
|
|
||||||
append_audio_meta(pFormatCtx, doc);
|
append_audio_meta(pFormatCtx, doc);
|
||||||
audio_stream = i;
|
audio_stream = i;
|
||||||
@ -251,10 +255,18 @@ void parse_media_format_ctx(scan_media_ctx_t *ctx, AVFormatContext *pFormatCtx,
|
|||||||
} else if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
} else if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
|
|
||||||
if (video_stream == -1) {
|
if (video_stream == -1) {
|
||||||
meta_line_t *meta_vid = malloc(sizeof(meta_line_t));
|
const AVCodecDescriptor *desc = avcodec_descriptor_get(stream->codecpar->codec_id);
|
||||||
meta_vid->key = MetaMediaVideoCodec;
|
|
||||||
meta_vid->int_val = stream->codecpar->codec_id;
|
if (desc != NULL) {
|
||||||
APPEND_META(doc, meta_vid)
|
meta_line_t *meta_vid = malloc(sizeof(meta_line_t));
|
||||||
|
meta_vid->key = MetaMediaVideoCodec;
|
||||||
|
strcpy(meta_vid->str_val, desc->name);
|
||||||
|
APPEND_META(doc, meta_vid)
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_line_t *meta_audio = malloc(sizeof(meta_line_t));
|
||||||
|
meta_audio->key = MetaMediaAudioCodec;
|
||||||
|
APPEND_META(doc, meta_audio)
|
||||||
|
|
||||||
meta_line_t *meta_w = malloc(sizeof(meta_line_t));
|
meta_line_t *meta_w = malloc(sizeof(meta_line_t));
|
||||||
meta_w->key = MetaWidth;
|
meta_w->key = MetaWidth;
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#include "scan.h"
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int fs_read(struct vfile *f, void *buf, size_t size) {
|
|
||||||
if (f->fd == -1) {
|
|
||||||
f->fd = open(f->filepath, O_RDONLY);
|
|
||||||
if (f->fd == -1) {
|
|
||||||
//TODO: log
|
|
||||||
// LOG_ERRORF(f->filepath, "open(): [%d] %s", errno, strerror(errno))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return read(f->fd, buf, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void fs_close(struct vfile *f) {
|
|
||||||
if (f->fd != -1) {
|
|
||||||
close(f->fd);
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,6 +7,11 @@
|
|||||||
|
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
|
||||||
|
// TODO: global init:
|
||||||
|
/*
|
||||||
|
* av_log_set_level(AV_LOG_QUIET);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define META_INT_MASK 0x80
|
#define META_INT_MASK 0x80
|
||||||
#define META_STR_MASK 0x40
|
#define META_STR_MASK 0x40
|
||||||
@ -33,8 +38,8 @@ enum metakey {
|
|||||||
MetaWidth = META_INT(2),
|
MetaWidth = META_INT(2),
|
||||||
MetaHeight = META_INT(3),
|
MetaHeight = META_INT(3),
|
||||||
MetaMediaDuration = META_LONG(4),
|
MetaMediaDuration = META_LONG(4),
|
||||||
MetaMediaAudioCodec = META_INT(5),
|
MetaMediaAudioCodec = META_STR(5),
|
||||||
MetaMediaVideoCodec = META_INT(6),
|
MetaMediaVideoCodec = META_STR(6),
|
||||||
MetaMediaBitrate = META_LONG(7),
|
MetaMediaBitrate = META_LONG(7),
|
||||||
MetaArtist = META_STR(8),
|
MetaArtist = META_STR(8),
|
||||||
MetaAlbum = META_STR(9),
|
MetaAlbum = META_STR(9),
|
||||||
@ -118,12 +123,12 @@ typedef struct parse_job_t {
|
|||||||
doc->meta_tail->next = meta;\
|
doc->meta_tail->next = meta;\
|
||||||
doc->meta_tail = meta;\
|
doc->meta_tail = meta;\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void fs_close(struct vfile *f);
|
#include "arc/arc.h"
|
||||||
|
#include "cbr/cbr.h"
|
||||||
#define CLOSE_FILE(f) if (f.close != NULL) {f.close(&f);};
|
#include "ebook/ebook.h"
|
||||||
|
#include "font/font.h"
|
||||||
int fs_read(struct vfile *f, void *buf, size_t size);
|
#include "media/media.h"
|
||||||
|
#include "ooxml/ooxml.h"
|
||||||
|
#include "text/text.h"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef SIST2_UTIL_H
|
#ifndef SCAN_UTIL_H
|
||||||
#define SIST2_UTIL_H
|
#define SCAN_UTIL_H
|
||||||
|
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
0
test/.gitkeep
Normal file
0
test/.gitkeep
Normal file
28
test/main.c
28
test/main.c
@ -1,28 +0,0 @@
|
|||||||
#include "../libscan/text/text.h"
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include "../libscan/arc/arc.h"
|
|
||||||
#include "../libscan/ebook/ebook.h"
|
|
||||||
#include "../libscan/ooxml/ooxml.h"
|
|
||||||
#include "../libscan/font/font.h"
|
|
||||||
|
|
||||||
#include <ft2build.h>
|
|
||||||
#include <freetype/freetype.h>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
scan_ebook_ctx_t ctx;
|
|
||||||
|
|
||||||
ctx.content_size = 100;
|
|
||||||
vfile_t file;
|
|
||||||
file.is_fs_file = TRUE;
|
|
||||||
file.filepath = "/home/simon/Downloads/libscan/CMakeLists.txt";
|
|
||||||
file.fd = open("/home/simon/Downloads/libscan/CMakeLists.txt", O_RDONLY);
|
|
||||||
file.read = fs_read;
|
|
||||||
|
|
||||||
document_t doc;
|
|
||||||
doc.meta_head = NULL;
|
|
||||||
doc.meta_tail = NULL;
|
|
||||||
|
|
||||||
doc.size = 200;
|
|
||||||
parse_ebook(&ctx, &file,"application/pdf", &doc);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user