FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
25 int 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 
53 static 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 }
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
pix
enum AVPixelFormat pix
Definition: ohcodec.c:55
oh_pix_map
static const struct @221 oh_pix_map[]
ohcodec.h
ff_oh_err_to_ff_err
int ff_oh_err_to_ff_err(OH_AVErrCode err)
Definition: ohcodec.c:25
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
error.h
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AV_PIX_FMT_NV21
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition: pixfmt.h:97
AV_PIX_FMT_NV12
@ 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
oh_pix
OH_AVPixelFormat oh_pix
Definition: ohcodec.c:54
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
ff_oh_pix_to_ff_pix
enum AVPixelFormat ff_oh_pix_to_ff_pix(OH_AVPixelFormat oh_pix)
Definition: ohcodec.c:63
AV_PIX_FMT_OHCODEC
@ AV_PIX_FMT_OHCODEC
Definition: pixfmt.h:500
ff_oh_pix_from_ff_pix
int ff_oh_pix_from_ff_pix(enum AVPixelFormat pix)
Definition: ohcodec.c:72