hi_v4l2.ko: decoder + encoder V4L2 stateful sobre HI_DRV_VDEC_*/HI_DRV_VENC_*. Decoder (/dev/video0): 6 codecs pixel-validados (H264/MPEG2/VP8/VP9/HEVC/MPEG-4), de-tile SW default-on (untile_plane, algoritmo do OMX vdec), capture kthread + back-pressure, CAPTURE vb2-vmalloc cached. ~37fps@1080p / 75fps@720p, v4l2-compliance 45/47. Encoder (/dev/video1): H264 (limite do VEDU), modelo desacoplado (capture kthread hi-venc-cap + feed-ahead + back-pressure + FIFO de src em voo), controles BITRATE/GOP_SIZE/H264_PROFILE/H264_LEVEL. ~42-52fps@1080p / 91fps@720p, dirigivel por gst v4l2h264enc / ffmpeg h264_v4l2m2m. Integracao in-tree no padrao dvb-hisi: Makefile inclui base.mak + MOD_NAME + lista de objetos; o parent drivers/msp/drv/Makefile pega o dir via objects +=. hi_v4l2 e obj-m (modulo) por depender de v4l2-mem2mem/videobuf2 (=m). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
80 lines
2.4 KiB
C
80 lines
2.4 KiB
C
/* Minimal libhicodec decoder test: H264 ES file -> NV21 frames file.
|
|
* Confirms whether the userspace AVPLAY + virtual VO window path produces
|
|
* LINEAR NV21 on this box (reference for the V4L2 VPSS-detile work).
|
|
* Build (host, cross): arm-linux-gnueabihf-gcc dectest.c -o dectest \
|
|
* -I<hicodec.h dir> -L<libhicodec.so dir> -lhicodec \
|
|
* -Wl,--unresolved-symbols=ignore-in-shared-libs
|
|
* Run (target): ./dectest /opt/big.264 /tmp/dec.nv21 20
|
|
*/
|
|
#include "hicodec.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
/* HI_SYS_Init (source/common): registers modules incl. the VO Dolby-lib status.
|
|
* Without it, vl_video_decoder_init -> HI_MPI_WIN_Init fails on
|
|
* HI_MPI_WIN_SetDolbyLibStatus. Mirrors the SDK samples (showiframe etc.). */
|
|
extern int HI_SYS_Init(void);
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
if (argc < 3) {
|
|
fprintf(stderr, "usage: %s in.264 out.nv21 [maxframes]\n", argv[0]);
|
|
return 1;
|
|
}
|
|
int maxf = (argc > 3) ? atoi(argv[3]) : 20;
|
|
SHICODEC codec;
|
|
memset(&codec, 0, sizeof(codec));
|
|
|
|
if (HI_SYS_Init() != 0)
|
|
fprintf(stderr, "warn: HI_SYS_Init nonzero (continuing)\n");
|
|
|
|
if (!vl_video_decoder_init(CODEC_ID_H264, &codec)) {
|
|
fprintf(stderr, "vl_video_decoder_init FAIL\n");
|
|
return 1;
|
|
}
|
|
fprintf(stderr, "CKPT: decoder_init OK\n");
|
|
|
|
FILE *fi = fopen(argv[1], "rb");
|
|
FILE *fo = fopen(argv[2], "wb");
|
|
if (!fi || !fo) { perror("fopen"); return 1; }
|
|
|
|
fseek(fi, 0, SEEK_END);
|
|
long sz = ftell(fi);
|
|
fseek(fi, 0, SEEK_SET);
|
|
unsigned char *es = malloc(sz);
|
|
if (fread(es, 1, sz, fi) != (size_t)sz) { fprintf(stderr, "read fail\n"); return 1; }
|
|
|
|
unsigned char *framebuf = malloc(3840 * 2160 * 3 / 2);
|
|
long off = 0, pts = 0;
|
|
int frames = 0;
|
|
|
|
while (off < sz && frames < maxf) {
|
|
int chunk = (sz - off > 65536) ? 65536 : (int)(sz - off);
|
|
fprintf(stderr, "CKPT: input off=%ld chunk=%d\n", off, chunk);
|
|
vl_video_decoder_input(&codec, es + off, chunk, pts);
|
|
off += chunk;
|
|
pts += 40000;
|
|
|
|
int osz;
|
|
uint8_t *out = framebuf;
|
|
int64_t opts = 0;
|
|
fprintf(stderr, "CKPT: draining\n");
|
|
while ((osz = vl_video_decoder_output(&codec, &out, &opts)) > 0
|
|
&& frames < maxf) {
|
|
fwrite(framebuf, 1, osz, fo);
|
|
frames++;
|
|
fprintf(stderr, "frame %d size=%d\n", frames, osz);
|
|
out = framebuf;
|
|
}
|
|
}
|
|
|
|
fprintf(stderr, "TOTAL frames=%d\n", frames);
|
|
vl_video_decoder_destroy(&codec);
|
|
fclose(fi);
|
|
fclose(fo);
|
|
free(es);
|
|
free(framebuf);
|
|
return 0;
|
|
}
|