FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/dovi_rpu.c
Date: 2024-04-25 05:10:44
Exec Total Coverage
Lines: 28 41 68.3%
Functions: 3 4 75.0%
Branches: 6 17 35.3%

Line Branch Exec Source
1 /*
2 * Dolby Vision RPU decoder
3 *
4 * Copyright (C) 2021 Jan Ekström
5 * Copyright (C) 2021-2024 Niklas Haas
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include "libavutil/mem.h"
25
26 #include "dovi_rpu.h"
27 #include "refstruct.h"
28
29 453 void ff_dovi_ctx_unref(DOVIContext *s)
30 {
31
2/2
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 453 times.
7701 for (int i = 0; i < FF_ARRAY_ELEMS(s->vdr); i++)
32 7248 ff_refstruct_unref(&s->vdr[i]);
33 453 ff_refstruct_unref(&s->ext_blocks);
34 453 av_free(s->rpu_buf);
35
36 453 *s = (DOVIContext) {
37 453 .logctx = s->logctx,
38 };
39 453 }
40
41 8 void ff_dovi_ctx_flush(DOVIContext *s)
42 {
43
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 8 times.
136 for (int i = 0; i < FF_ARRAY_ELEMS(s->vdr); i++)
44 128 ff_refstruct_unref(&s->vdr[i]);
45 8 ff_refstruct_unref(&s->ext_blocks);
46
47 8 *s = (DOVIContext) {
48 8 .logctx = s->logctx,
49 8 .cfg = s->cfg,
50 /* preserve temporary buffer */
51 8 .rpu_buf = s->rpu_buf,
52 8 .rpu_buf_sz = s->rpu_buf_sz,
53 };
54 8 }
55
56 32 void ff_dovi_ctx_replace(DOVIContext *s, const DOVIContext *s0)
57 {
58 32 s->logctx = s0->logctx;
59 32 s->cfg = s0->cfg;
60 32 s->header = s0->header;
61 32 s->mapping = s0->mapping;
62 32 s->color = s0->color;
63
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 32 times.
544 for (int i = 0; i <= DOVI_MAX_DM_ID; i++)
64 512 ff_refstruct_replace(&s->vdr[i], s0->vdr[i]);
65 32 ff_refstruct_replace(&s->ext_blocks, s0->ext_blocks);
66 32 }
67
68 int ff_dovi_guess_profile_hevc(const AVDOVIRpuDataHeader *hdr)
69 {
70 switch (hdr->vdr_rpu_profile) {
71 case 0:
72 if (hdr->bl_video_full_range_flag)
73 return 5;
74 break;
75 case 1:
76 if (hdr->el_spatial_resampling_filter_flag && !hdr->disable_residual_flag) {
77 if (hdr->vdr_bit_depth == 12) {
78 return 7;
79 } else {
80 return 4;
81 }
82 } else {
83 return 8;
84 }
85 }
86
87 return 0; /* unknown */
88 }
89