This avoids having to store it in the backup MPVEncContext.
Unified · Split
| @@ -2660,7 +2660,8 @@ static inline void copy_context_before_encode(MPVEncContext *const d, · 2659 unmodified lines | |||
| 2660 | } | 2660 | } |
| 2661 | 2661 | ||
| 2662 | static inline void copy_context_after_encode(MPVEncContext *const d, | 2662 | static inline void copy_context_after_encode(MPVEncContext *const d, |
| 2663 | const MPVEncContext *const s) | 2663 | const MPVEncContext *const s, |
| 2664 | int data_partitioning) | ||
| 2664 | { | 2665 | { |
| 2665 | int i; | 2666 | int i; |
| 2666 | 2667 | ||
| @@ -2684,7 +2685,7 @@ static inline void copy_context_after_encode(MPVEncContext *const d, · 17 unmodified lines | |||
| 2684 | d->c.mv_type = s->c.mv_type; | 2685 | d->c.mv_type = s->c.mv_type; |
| 2685 | d->c.mv_dir = s->c.mv_dir; | 2686 | d->c.mv_dir = s->c.mv_dir; |
| 2686 | d->pb= s->pb; | 2687 | d->pb= s->pb; |
| 2687 | if (s->c.data_partitioning) { | 2688 | if (data_partitioning) { |
| 2688 | d->pb2= s->pb2; | 2689 | d->pb2= s->pb2; |
| 2689 | d->tex_pb= s->tex_pb; | 2690 | d->tex_pb= s->tex_pb; |
| 2690 | } | 2691 | } |
| @@ -2744,7 +2745,7 @@ static void encode_mb_hq(MPVEncContext *const s, MPVEncContext *const backup, MP · 53 unmodified lines | |||
| 2744 | *dmin= score; | 2745 | *dmin= score; |
| 2745 | *next_block^=1; | 2746 | *next_block^=1; |
| 2746 | 2747 | ||
| 2747 | copy_context_after_encode(best, s); | 2748 | copy_context_after_encode(best, s, s->c.data_partitioning); |
| 2748 | } | 2749 | } |
| 2749 | } | 2750 | } |
| 2750 | 2751 | ||
| @@ -3165,8 +3166,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 414 unmodified lines | |||
| 3165 | 3166 | ||
| 3166 | copy_context_before_encode(&backup_s, s); | 3167 | copy_context_before_encode(&backup_s, s); |
| 3167 | backup_s.pb= s->pb; | 3168 | backup_s.pb= s->pb; |
| 3168 | best_s.c.data_partitioning = s->c.data_partitioning; | ||
| 3169 | best_s.c.partitioned_frame = s->c.partitioned_frame; | ||
| 3170 | if (s->c.data_partitioning) { | 3169 | if (s->c.data_partitioning) { |
| 3171 | backup_s.pb2= s->pb2; | 3170 | backup_s.pb2= s->pb2; |
| 3172 | backup_s.tex_pb= s->tex_pb; | 3171 | backup_s.tex_pb= s->tex_pb; |
| @@ -3390,7 +3389,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 217 unmodified lines | |||
| 3390 | } | 3389 | } |
| 3391 | } | 3390 | } |
| 3392 | 3391 | ||
| 3393 | copy_context_after_encode(s, &best_s); | 3392 | copy_context_after_encode(s, &best_s, s->c.data_partitioning); |
| 3394 | 3393 | ||
| 3395 | pb_bits_count= put_bits_count(&s->pb); | 3394 | pb_bits_count= put_bits_count(&s->pb); |
| 3396 | flush_put_bits(&s->pb); | 3395 | flush_put_bits(&s->pb); |