FFmpeg
Loading...
Searching...
No Matches
ohcodec.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * Copyright (c) 2025 Zhao Zhili <quinkblack@foxmail.com>
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "ohcodec.h"
22
23#include "libavutil/error.h"
24
25int ff_oh_err_to_ff_err(OH_AVErrCode err)
26{
27 switch (err) {
28 case AV_ERR_OK:
29 return 0;
30 case AV_ERR_NO_MEMORY:
31 return AVERROR(ENOMEM);
32 case AV_ERR_OPERATE_NOT_PERMIT:
33 return AVERROR(EPERM);
34 case AV_ERR_INVALID_VAL:
35 return AVERROR(EINVAL);
36 case AV_ERR_IO:
37 return AVERROR(EIO);
38 case AV_ERR_TIMEOUT:
39 return AVERROR(ETIMEDOUT);
40 case AV_ERR_UNKNOWN:
41 return AVERROR_UNKNOWN;
42 case AV_ERR_SERVICE_DIED:
43 return AVERROR_EXTERNAL;
44 case AV_ERR_INVALID_STATE:
45 return AVERROR(EINVAL);
46 case AV_ERR_UNSUPPORT:
47 return AVERROR(ENOTSUP);
48 default:
49 return AVERROR_EXTERNAL;
50 }
51}
52
53static const struct {
54 OH_AVPixelFormat oh_pix;
56} oh_pix_map[] = {
57 {AV_PIXEL_FORMAT_NV12, AV_PIX_FMT_NV12},
58 {AV_PIXEL_FORMAT_NV21, AV_PIX_FMT_NV21},
59 {AV_PIXEL_FORMAT_YUVI420, AV_PIX_FMT_YUV420P},
60 {AV_PIXEL_FORMAT_SURFACE_FORMAT, AV_PIX_FMT_OHCODEC},
61};
62
64{
65 for (size_t i = 0; i < FF_ARRAY_ELEMS(oh_pix_map); i++)
66 if (oh_pix_map[i].oh_pix == oh_pix)
67 return oh_pix_map[i].pix;
68
69 return AV_PIX_FMT_NONE;
70}
71
73{
74 for (size_t i = 0; i < FF_ARRAY_ELEMS(oh_pix_map); i++)
75 if (oh_pix_map[i].pix == pix)
76 return oh_pix_map[i].oh_pix;
77
78 return 0;
79}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
error code definitions
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition error.h:73
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition error.h:59
#define AVERROR(e)
Definition error.h:45
static const struct @341235340350303236323224312110037131221220006240 oh_pix_map[]
int ff_oh_pix_from_ff_pix(enum AVPixelFormat pix)
Definition ohcodec.c:72
enum AVPixelFormat pix
Definition ohcodec.c:55
enum AVPixelFormat ff_oh_pix_to_ff_pix(OH_AVPixelFormat oh_pix)
Definition ohcodec.c:63
int ff_oh_err_to_ff_err(OH_AVErrCode err)
Definition ohcodec.c:25
OH_AVPixelFormat oh_pix
Definition ohcodec.c:54
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:96
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition pixfmt.h:97
@ AV_PIX_FMT_OHCODEC
Definition pixfmt.h:500
#define FF_ARRAY_ELEMS(a)