FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mpeg4video.h
Go to the documentation of this file.
1 /*
2  * MPEG-4 encoder/decoder internal header.
3  * Copyright (c) 2000,2001 Fabrice Bellard
4  * Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef AVCODEC_MPEG4VIDEO_H
24 #define AVCODEC_MPEG4VIDEO_H
25 
26 #include <stdint.h>
27 
28 #include "mpegvideo.h"
29 
33 
34 /**
35  * @return the mb_type
36  */
38 
39 /**
40  * Predict the dc.
41  * @param n block index (0-3 are luma, 4-5 are chroma)
42  * @param dir_ptr pointer to an integer where the prediction direction will be stored
43  */
44 static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr)
45 {
46  int a, b, c, wrap, pred;
47  const int16_t *dc_val;
48 
49  /* find prediction */
50 
51  wrap = s->block_wrap[n];
52  dc_val = s->dc_val[0] + s->block_index[n];
53 
54  /* B C
55  * A X
56  */
57  a = dc_val[-1];
58  b = dc_val[-1 - wrap];
59  c = dc_val[-wrap];
60 
61  /* outside slice handling (we can't do that by memset as we need the
62  * dc for error resilience) */
63  if (s->first_slice_line && n != 3) {
64  if (n != 2)
65  b = c = 1024;
66  if (n != 1 && s->mb_x == s->resync_mb_x)
67  b = a = 1024;
68  }
69  if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1) {
70  if (n == 0 || n == 4 || n == 5)
71  b = 1024;
72  }
73 
74  if (abs(a - b) < abs(b - c)) {
75  pred = c;
76  *dir_ptr = 1; /* top */
77  } else {
78  pred = a;
79  *dir_ptr = 0; /* left */
80  }
81  return pred;
82 }
83 
84 #endif /* AVCODEC_MPEG4VIDEO_H */
b
#define b
Definition: input.c:41
mpegvideo.h
ff_mpeg4_init_direct_mv
void ff_mpeg4_init_direct_mv(MpegEncContext *s)
Definition: mpeg4video.c:83
mx
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
Definition: dsp.h:53
wrap
#define wrap(func)
Definition: neontest.h:65
s
#define s(width, name)
Definition: cbs_vp9.c:198
my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
Definition: dsp.h:53
ff_mpeg4_pred_dc
static int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr)
Predict the dc.
Definition: mpeg4video.h:44
abs
#define abs(x)
Definition: cuda_runtime.h:35
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ff_mpeg4_set_direct_mv
int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my)
Definition: mpeg4video.c:129
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
ff_mpeg4_get_video_packet_prefix_length
int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s)
Definition: mpeg4video.c:42
pred
static const float pred[4]
Definition: siprdata.h:259
ff_mpeg4_clean_buffers
void ff_mpeg4_clean_buffers(MpegEncContext *s)
Definition: mpeg4video.c:57
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:73