aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmpeg2
diff options
context:
space:
mode:
Diffstat (limited to 'libmpeg2')
-rw-r--r--libmpeg2/decode.c36
-rw-r--r--libmpeg2/mpeg2_internal.h6
-rw-r--r--libmpeg2/slice.c13
3 files changed, 45 insertions, 10 deletions
diff --git a/libmpeg2/decode.c b/libmpeg2/decode.c
index 9426f4ff59..451050d0bb 100644
--- a/libmpeg2/decode.c
+++ b/libmpeg2/decode.c
@@ -51,7 +51,7 @@ mpeg2_config_t config;
static int drop_flag = 0;
static int drop_frame = 0;
-#ifdef POSTPROC
+#ifdef MPEG12_POSTPROC
int quant_store[MBR+1][MBC+1]; // [Review]
#endif
@@ -86,7 +86,7 @@ void mpeg2_init (void)
motion_comp_init ();
}
-static vo_frame_t frames[3];
+static vo_frame_t frames[4];
void mpeg2_allocate_image_buffers (picture_t * picture)
{
@@ -100,7 +100,11 @@ void mpeg2_allocate_image_buffers (picture_t * picture)
buff_size = frame_size + (frame_size/4)*2; // 4Y + 1U + 1V
// allocate images in YV12 format
+#ifdef MPEG12_POSTPROC
+ for(i=0;i<4;i++){
+#else
for(i=0;i<3;i++){
+#endif
base = shmem_alloc(buff_size);
frames[i].base[0] = base;
frames[i].base[1] = base + frame_size * 5 / 4;
@@ -114,13 +118,6 @@ void mpeg2_allocate_image_buffers (picture_t * picture)
picture->backward_reference_frame=&frames[1];
picture->current_frame=&frames[2];
-#ifdef POSTPROC
- base = shmem_alloc(buff_size);
- picture->pp_frame[0] = base;
- picture->pp_frame[1] = base + frame_size * 5 / 4;
- picture->pp_frame[2] = base + frame_size;
-#endif
-
}
static void copy_slice (vo_frame_t * frame, uint8_t ** src){
@@ -157,6 +154,23 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer)
if (((picture->picture_structure == FRAME_PICTURE) ||
(picture->second_field))
) {
+#ifdef MPEG12_POSTPROC
+ if(picture->pp_options){
+ // apply OpenDivX postprocess filter
+ int stride[3];
+ stride[0]=picture->coded_picture_width;
+ stride[1]=stride[2]=stride[0]/2;
+ postprocess((picture->picture_coding_type == B_TYPE) ?
+ picture->current_frame->base :
+ picture->forward_reference_frame->base,
+ stride[0], frames[3].base, stride[0],
+ picture->coded_picture_width, picture->coded_picture_height,
+ &quant_store[1][1], (MBC+1), picture->pp_options);
+ output->draw_slice (frames[3].base, stride,
+ picture->display_picture_width,
+ picture->display_picture_height, 0, 0);
+ } else
+#endif
#if 1
if (picture->picture_coding_type != B_TYPE) {
int stride[3];
@@ -215,6 +229,10 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer)
} else {
if (picture->picture_coding_type == B_TYPE){
picture->current_frame = &frames[2];
+#ifdef MPEG12_POSTPROC
+ if(picture->pp_options)
+ picture->current_frame->copy=NULL; else
+#endif
picture->current_frame->copy=copy_slice;
} else {
picture->current_frame = picture->forward_reference_frame;
diff --git a/libmpeg2/mpeg2_internal.h b/libmpeg2/mpeg2_internal.h
index 046f37159a..ed278cc786 100644
--- a/libmpeg2/mpeg2_internal.h
+++ b/libmpeg2/mpeg2_internal.h
@@ -209,3 +209,9 @@ int slice_process (picture_t *picture, uint8_t code, uint8_t * buffer);
/* stats.c */
void stats_header (uint8_t code, uint8_t * buffer);
+
+#ifdef MPEG12_POSTPROC
+#define MBC 45
+#define MBR 36
+extern int quant_store[MBR+1][MBC+1]; // [Review]
+#endif
diff --git a/libmpeg2/slice.c b/libmpeg2/slice.c
index 5c235d86ca..04728cda36 100644
--- a/libmpeg2/slice.c
+++ b/libmpeg2/slice.c
@@ -1488,7 +1488,7 @@ do { \
dest[1] += 4 * stride; \
dest[2] += 4 * stride; \
} while (0); \
- offset = 0; \
+ offset = 0; ++code; \
} \
} while (0)
@@ -1739,6 +1739,9 @@ int slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
picture->dc_dct_pred[2] = 1 << (picture->intra_dc_precision+7);
}
+#ifdef MPEG12_POSTPROC
+ quant_store[code][(offset>>4)+1] = picture->quantizer_scale;
+#endif
offset += 16;
CHECK_DISPLAY;
@@ -1769,6 +1772,10 @@ int slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
else
MOTION (motion_fi_zero, MACROBLOCK_MOTION_FORWARD);
+#ifdef MPEG12_POSTPROC
+ quant_store[code][(offset>>4)+1] = picture->quantizer_scale;
+#endif
+
offset += 16;
CHECK_DISPLAY;
} while (--mba_inc);
@@ -1781,6 +1788,10 @@ int slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
else
MOTION (motion_fi_reuse, macroblock_modes);
+#ifdef MPEG12_POSTPROC
+ quant_store[code][(offset>>4)+1] = picture->quantizer_scale;
+#endif
+
offset += 16;
CHECK_DISPLAY;
} while (--mba_inc);