| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include "libavutil/avassert.h" | ||
| 20 | #include "libavutil/mem.h" | ||
| 21 | #include "error_resilience.h" | ||
| 22 | #include "mpegvideo.h" | ||
| 23 | #include "mpegvideodec.h" | ||
| 24 | #include "mpeg_er.h" | ||
| 25 | |||
| 26 | 34242 | static void set_erpic(ERPicture *dst, const MPVPicture *src) | |
| 27 | { | ||
| 28 | int i; | ||
| 29 | |||
| 30 | 34242 | memset(dst, 0, sizeof(*dst)); | |
| 31 |
2/2✓ Branch 0 taken 315 times.
✓ Branch 1 taken 33927 times.
|
34242 | if (!src) |
| 32 | 315 | return; | |
| 33 | |||
| 34 | 33927 | dst->f = src->f; | |
| 35 | 33927 | dst->progress = &src->progress; | |
| 36 | |||
| 37 |
2/2✓ Branch 0 taken 67854 times.
✓ Branch 1 taken 33927 times.
|
101781 | for (i = 0; i < 2; i++) { |
| 38 | 67854 | dst->motion_val[i] = src->motion_val[i]; | |
| 39 | 67854 | dst->ref_index[i] = src->ref_index[i]; | |
| 40 | } | ||
| 41 | |||
| 42 | 33927 | dst->mb_type = src->mb_type; | |
| 43 | 33927 | dst->field_picture = src->field_picture; | |
| 44 | } | ||
| 45 | |||
| 46 | 11414 | void ff_mpeg_er_frame_start(MpegEncContext *s) | |
| 47 | { | ||
| 48 | 11414 | ERContext *er = &s->er; | |
| 49 | |||
| 50 | 11414 | set_erpic(&er->cur_pic, s->cur_pic.ptr); | |
| 51 | 11414 | set_erpic(&er->next_pic, s->next_pic.ptr); | |
| 52 | 11414 | set_erpic(&er->last_pic, s->last_pic.ptr); | |
| 53 | |||
| 54 | 11414 | er->quarter_sample = s->quarter_sample; | |
| 55 | |||
| 56 | 11414 | ff_er_frame_start(er); | |
| 57 | 11414 | } | |
| 58 | |||
| 59 | 59282 | static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, | |
| 60 | int (*mv)[2][4][2], int mb_x, int mb_y, | ||
| 61 | int mb_intra, int mb_skipped) | ||
| 62 | { | ||
| 63 | 59282 | MpegEncContext *s = opaque; | |
| 64 | |||
| 65 | av_assert1(!mb_intra); | ||
| 66 | |||
| 67 | 59282 | s->mv_dir = mv_dir; | |
| 68 | 59282 | s->mv_type = mv_type; | |
| 69 | 59282 | s->mb_intra = mb_intra; | |
| 70 | 59282 | s->mb_skipped = mb_skipped; | |
| 71 | 59282 | s->mb_x = mb_x; | |
| 72 | 59282 | s->mb_y = mb_y; | |
| 73 | 59282 | s->mcsel = 0; | |
| 74 | 59282 | memcpy(s->mv, mv, sizeof(*mv)); | |
| 75 | |||
| 76 | // The following disables unquantizing and the IDCT. | ||
| 77 |
2/2✓ Branch 0 taken 711384 times.
✓ Branch 1 taken 59282 times.
|
770666 | for (size_t i = 0; i < FF_ARRAY_ELEMS(s->block_last_index); i++) |
| 78 | 711384 | s->block_last_index[i] = -1; | |
| 79 | |||
| 80 | 59282 | s->dest[0] = s->cur_pic.data[0] + | |
| 81 | 59282 | s->mb_y * 16 * s->linesize + | |
| 82 | 59282 | s->mb_x * 16; | |
| 83 | 59282 | s->dest[1] = s->cur_pic.data[1] + | |
| 84 | 59282 | s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + | |
| 85 | 59282 | s->mb_x * (16 >> s->chroma_x_shift); | |
| 86 | 59282 | s->dest[2] = s->cur_pic.data[2] + | |
| 87 | 59282 | s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + | |
| 88 | 59282 | s->mb_x * (16 >> s->chroma_x_shift); | |
| 89 | |||
| 90 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59282 times.
|
59282 | if (ref) |
| 91 | ✗ | av_log(s->avctx, AV_LOG_DEBUG, | |
| 92 | "Interlaced error concealment is not fully implemented\n"); | ||
| 93 | 59282 | ff_mpv_reconstruct_mb(s, NULL); | |
| 94 | 59282 | } | |
| 95 | |||
| 96 | 649 | av_cold int ff_mpeg_er_init(MpegEncContext *s) | |
| 97 | { | ||
| 98 | 649 | ERContext *er = &s->er; | |
| 99 | 649 | int mb_array_size = s->mb_height * s->mb_stride; | |
| 100 | |||
| 101 | 649 | er->avctx = s->avctx; | |
| 102 | |||
| 103 | 649 | er->mb_index2xy = s->mb_index2xy; | |
| 104 | 649 | er->mb_num = s->mb_num; | |
| 105 | 649 | er->mb_width = s->mb_width; | |
| 106 | 649 | er->mb_height = s->mb_height; | |
| 107 | 649 | er->mb_stride = s->mb_stride; | |
| 108 | 649 | er->b8_stride = s->b8_stride; | |
| 109 | |||
| 110 | 649 | er->dc_val[0] = s->dc_val; | |
| 111 | 649 | er->dc_val[1] = er->dc_val[0] + s->b8_stride * 2 * s->buffer_pools.alloc_mb_height + s->mb_stride; | |
| 112 | 649 | er->dc_val[2] = er->dc_val[1] + s->mb_stride * (s->buffer_pools.alloc_mb_height + 1); | |
| 113 | |||
| 114 | 649 | er->er_temp_buffer = av_malloc(s->mb_height * s->mb_stride * (4*sizeof(int) + 1)); | |
| 115 | 649 | er->error_status_table = av_mallocz(mb_array_size); | |
| 116 |
2/4✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 649 times.
|
649 | if (!er->er_temp_buffer || !er->error_status_table) |
| 117 | ✗ | goto fail; | |
| 118 | |||
| 119 | 649 | er->mbskip_table = s->mbskip_table; | |
| 120 | 649 | er->mbintra_table = s->mbintra_table; | |
| 121 | |||
| 122 | 649 | er->decode_mb = mpeg_er_decode_mb; | |
| 123 | 649 | er->opaque = s; | |
| 124 | |||
| 125 | 649 | return 0; | |
| 126 | ✗ | fail: | |
| 127 | ✗ | av_freep(&er->er_temp_buffer); | |
| 128 | ✗ | av_freep(&er->error_status_table); | |
| 129 | ✗ | return AVERROR(ENOMEM); | |
| 130 | } | ||
| 131 |